我希望使用 preg_split 像电话号码一样显示一个数字:
$number = '1234567890';
// preg_split
$number = '123 456 7890';
例如也许:
implode(' ', preg_split('/pattern/', $number))
我希望使用 preg_split 像电话号码一样显示一个数字:
$number = '1234567890';
// preg_split
$number = '123 456 7890';
例如也许:
implode(' ', preg_split('/pattern/', $number))
$number = '1234567890';
$number = preg_replace('/(\d{3})(\d{3})(\d{4})/','$1 $2 $3',$number);
试试这个-
$str = "1234567890";
$split = str_split($str, 3);
echo $split[0]." ".$split[1]." ".$split[2].$split[3];
或者
$number= "1234567890";
echo substr($number,0,3)." ".substr($number,3,3)." ".substr($number,5);