2つの文字列が一致するかどうかを判断しようとしていますが、それらを印刷しても一致していても一致しないと言います。私は、文字列としてそれらの両方をキャストしようとした、と私は代わりに「==」の「===」を使用してみましたが、どちらも問題を解決した...PHPでの変数の比較の問題
if(preg_match("#^Availability:#", $test)) {
//just to note: $test = "Availability: Lorem Ipsum";
$nid = 1;
$prep = explode("Availability:", $test);
$orig = node_load($nid);
print $prep[1]; //Prints Lorem Ipsum
print($orig->title); //Prints Lorem Ipsum
if((string)$orig->title == (string)$prep[1]) {
print 'ok';
} else {
print 'nope'; //Always prints nope
}
...
おそらく改行/空白の問題です。両方の値に対して 'trim()'を実行して、それらが一致するかどうか確認できますか? –