开发者

PHP value doesn't equal to what it echoes

I got a value in $array[1] and I want to know what it is, so I can compare it in other parts of my code.

So I echo out $array[1] and I get "vrij &nbsp &nbsp " or "vrij "

$value = $array[1];
echo $value ; // outputs "vrij     "
if($value = $array[1]){
    echo "TRUE 1";
} 
if($value = "vrij     "){ 
   echo "TRUE 2";
}

The开发者_Python百科 problem is, it only echo's TRUE 1. I copy pasted the echo exactly but it doesn't return TRUE 2


You're assigning the value of $array[1] to $value, not comparing them. Change the = into == inside the if clauses.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜