Strange strpos behaviour
Posted: Tue Aug 08, 2006 3:47 pm
Can someone test this for me:
I get:
Which means strpos thinks the marked characters are == '}'
43 points to 't' ?!
Code: Select all
function tokenPositions($msg)
{
$token = '}';
$i = strpos($msg, $token);
while ($i !== false) {
$arr[] = $i;
$i = strpos($msg, $token, $i+1);
}
return print_r($arr, true);
}
$testTxt = "{label} is } an error{ {numErrors} i{sn't t}hat {ida}} {{tooltip} ";
echo tokenPositions($testTxt);Code: Select all
Array ( [0] => 6 [1] => 11 [2] => 33 [3] => 43 [4] => 52 [5] => 53 [6] => 64 )Code: Select all
{label} is } an error{ {numErrors} i{sn\'t that {ida}} {{tooltip}
^ ^ ^ ^ ^^ ^