- mb_strpos: documentation ( source)
- strpos: documentation ( source)
<?php
$original_multibyte_string = 'țată în HERE';
$a_non_multibyte_str_same_length = '123456789HERE';
// HERE is on 10th (9th element) character
echo 'strpos finds HERE at: '.strpos($original_multibyte_string,'HERE').' '.'strpos finds HERE at: '.strpos($a_non_multibyte_str_same_length,'HERE');
// OUTPUTS: strpos finds HERE at: 12 mb_strpos finds HERE at: 9
echo "\n";
// now lets test the multibyte:
echo 'mb_strpos finds HERE at: '.mb_strpos($original_multibyte_string,'HERE','UTF-8').' '.'mb_strpos finds HERE at: '.mb_strpos($a_non_multibyte_str_same_length,'HERE','UTF-8');