php - strpos issue with 0==false? -
i'm using strpos find position of string in string. first check if string found @ in there. here's line:
if (strpos($grafik['data'],$ss1)<>false && strpos($grafik['data'],$ss2)<>false && strpos($grafik['data'],$ss1) < strpos($grafik['data'],$ss2))
i check if both strings contained , want first 1 placed before second one. in php manual says strpos returns false when string not found. if string starts @ 0 position (strpos returns 0 since beginning), seems statement
strpos($grafik['data'],$ss1)<>false
is false. somehow 0==false ? how make statement true when strpos returns 0 ?
from http://www.php.net/manual/en/function.strpos.php:
warning
this function may return boolean false, may return non-boolean value evaluates false, such 0 or "". please read section on booleans more information. use the === operator testing return value of function.
you have use ===
operator instead of ==
.
in case, instead of using <>
, use !==
:
strpos($grafik['data'], $ss1) !== false
this return true if $ss1
found in $grafik['data']
Comments
Post a Comment