我希望使用preg_split:
将数字显示为电话号码$number = '1234567890';
// preg_split
$number = '123 456 7890';
e.g。也许:
implode(' ', preg_split('/pattern/', $number))
答案 0 :(得分:4)
$number = '1234567890';
$number = preg_replace('/(\d{3})(\d{3})(\d{4})/','$1 $2 $3',$number);
答案 1 :(得分:0)
试试这个 -
$str = "1234567890";
$split = str_split($str, 3);
echo $split[0]." ".$split[1]." ".$split[2].$split[3];
OR
$number= "1234567890";
echo substr($number,0,3)." ".substr($number,3,3)." ".substr($number,5);