时间:2021-07-01 10:21:17 帮助过:104人阅读
$a = 'aaa,bbb,ccc,"eee,ccc,sss,ppp",dddd,iiii,cccc';
在线等,请大侠来指点。
$a = 'aaa,bbb,ccc,"eee,ccc,sss,ppp",dddd,iiii,cccc';echo preg_replace_callback('/".+?"/', function($r) { return str_replace(',', ' ', $r[0]);}, $a);aaa,bbb,ccc,"eee ccc sss ppp",dddd,iiii,cccc
$a = 'aaa,bbb,ccc,"eee,ccc,sss,ppp",dddd,iiii,cccc';$new=preg_replace('/"(.+?)"/ies',"replace('\\1')",$a);echo $new;//aaa,bbb,ccc,"eeecccsssppp",dddd,iiii,ccccfunction replace($str){ $return=str_replace(',','',$str); return '"'.$return.'"';}
$a = 'aaa,bbb,ccc,"eee,ccc,sss,ppp",dddd,iiii,cccc';echo preg_replace('/(?<=")(.+?)(?=")/e', 'str_replace(",", " ", "$1")',$a);
楼上都是高手