Answer the question
In order to leave comments, you need to log in
Why does preg_match determine the position incorrectly if there are diacritics in the string?
$str = 'ab'. mb_convert_encoding( '́', 'UTF-8', 'HTML-ENTITIES' ). 'cdef';
// $str = ab́cdef
preg_match( '#de#ui', $str, $matches, PREG_OFFSET_CAPTURE );
// $matches = Array ( [0] => Array ( [0] => de [1] => 5 ) )
$subs = mb_substr( $str, $matches[0][1], null, 'UTF-8' );
// $subs = ef
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question