3v4l.org

run code in 200+ php & hhvm versions
<?php // n-dashes are encoded as byte sequence \xe2\x80\x93 in UTF-8 $str = 'foo–bar–baz'; // take substring of 4 bytes length starting with the 4th byte var_dump(mb_strcut($str, 4, 4, 'UTF-8')); // take substring of 4 code points length starting with the 4th code point var_dump(mb_substr($str, 4, 4, 'UTF-8'));
Output for 4.3.0 - 7.3.0
string(4) "–b" string(6) "bar–"