Jump to content

if function does not work correctly


ted_chou12

Recommended Posts

i used a function: $result = array_keys($array1, $id);
and I used $result[0] obtains the first figure of the result outputted, looks like:
[code]Array ( [0] => color [1] => size )[/code]
So in the case above, color will be outputed...
although the echo $result[0] works perfectly fine (i got expected result) however, when I want to plug this output value to a if statement, it doesnt work:
if ($result[0] != "") {echo "test".$result[0]."test";}
it simply does not recognize the value, i dont understand, because the if clause does not differenciate between "..."(some value) and ""(no value).
Hope it is understandable.
Thanks
Ted
Link to comment
https://forums.phpfreaks.com/topic/35659-if-function-does-not-work-correctly/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.