I need to write an if condition to detect blank string on PHP. But the variable may get numbers also. So I write the condition like follows. While the variable get the value zero "0" as number the condition detect it as blank ""
$string = array_search("value match", $array); //$string = 0;
if($string == "")
{
echo "not equal";
}
Is it a bug on PHP? How we can detect for blank value (not null) for a variable which may have numbers or string?
$stringis not a string but an integer. And that0 == ""is intended behavior.$string = array_search("value match", $array);. If there is no search match i have to detect it by if condition.$string !== false?$string === falsethen how0escape from equal to false?. Any how your idea works for my requirement. Thank you.