Jamers Posted December 27, 2014 Report Share Posted December 27, 2014 很简单的功能,用preg_replace一次搞定 function cleanstr($str,$ary='') { /* Jamers 2013.06.27 清除字符串内无效字符 */ $tt = '*,?,-,/,.,:,\\'; if ($ary != '') $tt = $ary; $t = explode(',',$tt); $p = array(); $r = array(); foreach($t as $v) { $p[] = '/\\'.$v.'/'; $r[] = ''; } return preg_replace($p,$r,$str); } Link to comment Share on other sites More sharing options...
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now