<?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 文字
- Output for 8.2.0 - 8.2.26, 8.3.0 - 8.3.4, 8.3.6 - 8.3.15, 8.4.1 - 8.4.2
- 👩👩👧👧
25
7
13
array(25) {
[0]=>
string(1) "�"
[1]=>
string(1) "�"
[2]=>
string(1) "�"
[3]=>
string(1) "�"
[4]=>
string(1) "�"
[5]=>
string(1) "�"
[6]=>
string(1) "�"
[7]=>
string(1) "�"
[8]=>
string(1) "�"
[9]=>
string(1) "�"
[10]=>
string(1) "�"
[11]=>
string(1) "�"
[12]=>
string(1) "�"
[13]=>
string(1) "�"
[14]=>
string(1) "�"
[15]=>
string(1) "�"
[16]=>
string(1) "�"
[17]=>
string(1) "�"
[18]=>
string(1) "�"
[19]=>
string(1) "�"
[20]=>
string(1) "�"
[21]=>
string(1) "�"
[22]=>
string(1) "�"
[23]=>
string(1) "�"
[24]=>
string(1) "�"
}
array(7) {
[0]=>
string(4) "👩"
[1]=>
string(3) ""
[2]=>
string(4) "👩"
[3]=>
string(3) ""
[4]=>
string(4) "👧"
[5]=>
string(3) ""
[6]=>
string(4) "👧"
}
Fatal error: Uncaught TypeError: mb_str_split(): Argument #2 ($length) must be of type int, string given in /in/Qme05:10
Stack trace:
#0 /in/Qme05(10): mb_str_split('\xF0\x9F\x91\xA9\xE2\x80\x8D\xF0\x9F\x91\xA9\xE2\x80\x8D\xF0...', 'UTH-16')
#1 {main}
thrown in /in/Qme05 on line 10
Process exited with code 255. - Output for 8.3.5
- Warning: PHP Startup: Unable to load dynamic library 'sodium.so' (tried: /usr/lib/php/8.3.5/modules/sodium.so (libsodium.so.23: cannot open shared object file: No such file or directory), /usr/lib/php/8.3.5/modules/sodium.so.so (/usr/lib/php/8.3.5/modules/sodium.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
👩👩👧👧
25
7
13
array(25) {
[0]=>
string(1) "�"
[1]=>
string(1) "�"
[2]=>
string(1) "�"
[3]=>
string(1) "�"
[4]=>
string(1) "�"
[5]=>
string(1) "�"
[6]=>
string(1) "�"
[7]=>
string(1) "�"
[8]=>
string(1) "�"
[9]=>
string(1) "�"
[10]=>
string(1) "�"
[11]=>
string(1) "�"
[12]=>
string(1) "�"
[13]=>
string(1) "�"
[14]=>
string(1) "�"
[15]=>
string(1) "�"
[16]=>
string(1) "�"
[17]=>
string(1) "�"
[18]=>
string(1) "�"
[19]=>
string(1) "�"
[20]=>
string(1) "�"
[21]=>
string(1) "�"
[22]=>
string(1) "�"
[23]=>
string(1) "�"
[24]=>
string(1) "�"
}
array(7) {
[0]=>
string(4) "👩"
[1]=>
string(3) ""
[2]=>
string(4) "👩"
[3]=>
string(3) ""
[4]=>
string(4) "👧"
[5]=>
string(3) ""
[6]=>
string(4) "👧"
}
Fatal error: Uncaught TypeError: mb_str_split(): Argument #2 ($length) must be of type int, string given in /in/Qme05:10
Stack trace:
#0 /in/Qme05(10): mb_str_split('\xF0\x9F\x91\xA9\xE2\x80\x8D\xF0\x9F\x91\xA9\xE2\x80\x8D\xF0...', 'UTH-16')
#1 {main}
thrown in /in/Qme05 on line 10
Process exited with code 255. - Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.31
- 👩👩👧👧
25
7
12
array(25) {
[0]=>
string(1) "�"
[1]=>
string(1) "�"
[2]=>
string(1) "�"
[3]=>
string(1) "�"
[4]=>
string(1) "�"
[5]=>
string(1) "�"
[6]=>
string(1) "�"
[7]=>
string(1) "�"
[8]=>
string(1) "�"
[9]=>
string(1) "�"
[10]=>
string(1) "�"
[11]=>
string(1) "�"
[12]=>
string(1) "�"
[13]=>
string(1) "�"
[14]=>
string(1) "�"
[15]=>
string(1) "�"
[16]=>
string(1) "�"
[17]=>
string(1) "�"
[18]=>
string(1) "�"
[19]=>
string(1) "�"
[20]=>
string(1) "�"
[21]=>
string(1) "�"
[22]=>
string(1) "�"
[23]=>
string(1) "�"
[24]=>
string(1) "�"
}
array(7) {
[0]=>
string(4) "👩"
[1]=>
string(3) ""
[2]=>
string(4) "👩"
[3]=>
string(3) ""
[4]=>
string(4) "👧"
[5]=>
string(3) ""
[6]=>
string(4) "👧"
}
Fatal error: Uncaught TypeError: mb_str_split(): Argument #2 ($length) must be of type int, string given in /in/Qme05:10
Stack trace:
#0 /in/Qme05(10): mb_str_split('\xF0\x9F\x91\xA9\xE2\x80\x8D\xF0\x9F\x91\xA9\xE2\x80\x8D\xF0...', 'UTH-16')
#1 {main}
thrown in /in/Qme05 on line 10
Process exited with code 255. - Output for 7.4.0 - 7.4.33
- 👩👩👧👧
25
7
12
array(25) {
[0]=>
string(1) "�"
[1]=>
string(1) "�"
[2]=>
string(1) "�"
[3]=>
string(1) "�"
[4]=>
string(1) "�"
[5]=>
string(1) "�"
[6]=>
string(1) "�"
[7]=>
string(1) "�"
[8]=>
string(1) "�"
[9]=>
string(1) "�"
[10]=>
string(1) "�"
[11]=>
string(1) "�"
[12]=>
string(1) "�"
[13]=>
string(1) "�"
[14]=>
string(1) "�"
[15]=>
string(1) "�"
[16]=>
string(1) "�"
[17]=>
string(1) "�"
[18]=>
string(1) "�"
[19]=>
string(1) "�"
[20]=>
string(1) "�"
[21]=>
string(1) "�"
[22]=>
string(1) "�"
[23]=>
string(1) "�"
[24]=>
string(1) "�"
}
array(7) {
[0]=>
string(4) "👩"
[1]=>
string(3) ""
[2]=>
string(4) "👩"
[3]=>
string(3) ""
[4]=>
string(4) "👧"
[5]=>
string(3) ""
[6]=>
string(4) "👧"
}
Warning: mb_str_split() expects parameter 2 to be int, string given in /in/Qme05 on line 10
NULL
array(1) {
[0]=>
string(3) "�"
}
- Output for 7.3.0 - 7.3.33
- 👩👩👧👧
25
7
12
array(25) {
[0]=>
string(1) "�"
[1]=>
string(1) "�"
[2]=>
string(1) "�"
[3]=>
string(1) "�"
[4]=>
string(1) "�"
[5]=>
string(1) "�"
[6]=>
string(1) "�"
[7]=>
string(1) "�"
[8]=>
string(1) "�"
[9]=>
string(1) "�"
[10]=>
string(1) "�"
[11]=>
string(1) "�"
[12]=>
string(1) "�"
[13]=>
string(1) "�"
[14]=>
string(1) "�"
[15]=>
string(1) "�"
[16]=>
string(1) "�"
[17]=>
string(1) "�"
[18]=>
string(1) "�"
[19]=>
string(1) "�"
[20]=>
string(1) "�"
[21]=>
string(1) "�"
[22]=>
string(1) "�"
[23]=>
string(1) "�"
[24]=>
string(1) "�"
}
Fatal error: Uncaught Error: Call to undefined function mb_str_split() in /in/Qme05:9
Stack trace:
#0 {main}
thrown in /in/Qme05 on line 9
Process exited with code 255.
preferences:
91.1 ms | 417 KiB | 5 Q