請問如何把一串字的所有符號或空白都替換成 「-」呢包括,?@%!$&*(什麼的)
preg_replace是一种方法,这里我提供另外一种方法,参看下面代码
$str = 'hello %abc?11'; $patten = array( '【', '】', '「', '?', '%', '&' ); $rs = str_replace(' ','',str_replace($patten,'「-」',$str)); echo $rs;
1.2m questions
2.1m answers
5 comments
56.1k users