时间:2021-07-01 10:21:17 帮助过:3人阅读
$en=array("Mon-Fri","Sat","Sun");
$cn=array("周一~周五","周六","周日");
$str=str_replace($en, $cn, $str);
可以在你的代码的基础上加增加
$str = preg_replace('/-/','~',$str,1);
$str="Mon-Fri 8:00-23:00; Sat 10:00-23:00; Sun 10:00-22:00"; $en=array("Mon", "Fri","Sat","Sun"); $cn=array("周一", "周五","周六","周日"); $str=str_replace($en, $cn, $str); //echo $str; $a[0]='/([^\d]+)\-/'; $a[1]='/\s(\d)/'; $b[0]='\1~'; $b[1]='\1'; $str=preg_replace($a,$b, $str); echo $str;
就是楼上这样!