- mb_strlen: documentation ( source)
- json_encode: documentation ( source)
<?php
$str = '🏴';
$res = [
'strlen' => strlen($str),
'mb_strlen' => mb_strlen($str),
'grapheme_strlen' => grapheme_strlen($str),
];
echo json_encode($res, JSON_PRETTY_PRINT);
/*
{
"strlen": 28,
"mb_strlen": 7,
"grapheme_strlen": 1
}
*/