- mb_substr: documentation ( source)
- mb_strlen: documentation ( source)
- array_slice: documentation ( source)
- preg_split: documentation ( source)
- ord: documentation ( source)
- join: documentation ( source)
<?php
$string = "♫";
$len = mb_strlen($string, '8bit');
function substr_unicode($str, $s, $l = null) {
return join("", array_slice(
preg_split("//u", $str, -1, PREG_SPLIT_NO_EMPTY), $s, $l));
}
echo ord(mb_substr($string, 0, $len))." ";
echo chr(153), chr(171);