<?php
function codePoints($utf8_str){
//入力をUTF-32に変換
$utf32_str=mb_convert_encoding($utf8_str,'UTF-32','UTF-8');
for($i=0;$i<mb_strlen($utf32_str,'UTF-32');++$i)
//1文字ずつ16進文字列に変換
$result[]=bin2hex(mb_substr($utf32_str,$i,1,'UTF-32'));
return $result;
}
//mb_internal_encoding('UTF-8');
$string ='aab';
$pattern = '/aaa/';
if(preg_match_all($pattern,
$string,
$matches,
PREG_OFFSET_CAPTURE)) {
echo 'test';
}
$string ="⏰";
$test = codePoints($string);
echo "$test:".print_r($test,true);
$pattern = '/23f0|23f3/';
if(preg_match_all($pattern,
$test[0],
$matches
)) {
echo 'test2';
}
preferences:
28.3 ms | 402 KiB | 5 Q