3v4l.org

run code in 500+ PHP versions simultaneously
<?php $input = '🧪 test'; $encodings = ['utf-8', 'utf-16', 'utf-32']; foreach ($encodings as $to) { var_dump([ 'to' => $to, 'mb_substr' => mb_substr($input, 3, 4, $to), 'iconv_substr' => iconv_substr($input, 3, 4, $to), 'substr' => substr($input, 3, 4), 'substr+utf8_encode' => substr(utf8_encode($input), 3, 4), 'substr+utf8_decode' => substr(utf8_decode($input), 3, 4) ]); }

preferences:
104.59 ms | 1648 KiB | 5 Q