2012-06-28 149 views

回答

1
str_replace("char_to_rep","",$string); // replacing with nothing means deleting 


也REF。 how-to-remove-html-special-chars

+0

$ content = str_replace('\\','',$ content); –

+0

$ string = preg_replace(「/&#?[a-z0-9] {2,8};/i」,「」,$ input); –

0

使用str_replace,並與空字符

+0

什麼是'string_replace'? – j0k

+0

沒有這樣的string_replace。感謝您指點。我編輯過! –

0
str_replace("#"," ",$string) 

替換特殊字符試試這個代碼的所有特殊字符

0

非常感謝您的幫助,但有沒有更好的方法來做到這一點?

$post = '(&repl^eac&e_+'; 

    function repleace($post) { 
     $array = array('.html', '.php', '±', '§', '!', '@', '€', '`', '#', '$', '%', '^', '&', '*', '(', ')', '+', '=', '<', '>', '?', '/', '|', '[', ']', ':', ';', ',', '~', '.'); 
     $post = str_replace($array, '', $post); 
     $post = str_replace(' ', '_', $post); 
     $post = str_replace('-', '_', $post); 
     return strtolower('/'.$post.'/'); 
    } 
0
function($input) { 
    $input = preg_replace("/&#?[a-z0-9]{2,8};/i","",$input); 
    $input = ucfirst($input); 
    return $input; 
} 

的/ &#內的PHP pre_repleace函數[A-Z0-9] {2,8};/I字符工作正常。