php在字符串中添加-
发布网友
发布时间:2022-04-06 03:20
我来回答
共2个回答
热心网友
时间:2022-04-06 04:49
<?php
$a=2018081206;
$b=substr($a,0,4);
$c=substr($a,4);
echo $b.'-'.substr(chunk_split($c,2,"-"), 0, -1);
热心网友
时间:2022-04-06 06:07
<?php
$a=2018081206;
$n[]=substr($a,0,4);
$n[]=substr($a,4,2);
$n[]=substr($a,6,2);
$n[]=substr($a,8,2);
$a=implode("-",$n);
?>