I am facing realy strange problem i am trying to find a UTF-8 needle in UTF-8 haystack and it just dont want to work properly. Here is an example.
header('Content-Type: text/html; charset=utf-8');
mb_internal_encoding("UTF-8");
vardump(mb_strpos('Příkon', 'Příkon '));
It returns false
header('Content-Type: text/html; charset=utf-8');
mb_internal_encoding("UTF-8");
vardump(mb_strpos('Příkon', 'Příkon'));
this returns 0 (success)
Any ideas?
Well, yes. The error is correct. You've just swapped the $haystack
and $needle
when calling mb_strpos(string $haystack , string $needle)
and so 'Příkon '
can not be found in 'Příkon'
. Your call should look like
mb_strpos('Příkon ', 'Příkon');