- var_dump: documentation ( source)
- mb_strlen: documentation ( source)
- preg_match: documentation ( source)
- str_split: documentation ( source)
- mb_str_split: documentation ( source)
<?php
$emoji = '๐ฉโ๐ฉโ๐งโ๐ง';
echo $emoji. "\n";
echo strlen($emoji) . "\n";// 25
echo mb_strlen($emoji) . "\n";// 7
echo mb_strlen($emoji, "UTF-16") . "\n";// 12
var_dump(str_split($emoji)); // ่ฌใฎ 25 ๆๅญ้
ๅ
var_dump(mb_str_split($emoji)); // ็ตตๆๅญ 4 ใคใจ้ทใ 3 ใจใใใ่ฆใ็ฎใใๆๅญๅ 3 ใคใฎ 7 ๆๅญ้
ๅ
var_dump(mb_str_split($emoji, 'UTH-16')); // ็ตตๆๅญ 4 ใคใจ้ทใ 3 ใจใใใ่ฆใ็ฎใใๆๅญๅ 3 ใคใฎ 7 ๆๅญ้
ๅ
preg_match('/.{1,3}/', $emoji, $match);
var_dump($match);// ่ฌใฎ 3 ๆๅญ