- var_dump: documentation ( source)
- mb_substr: documentation ( source)
- mb_strcut: documentation ( source)
<?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'));