2013-09-01 103 views
1

其實我已經使用str_replace函數的問題,我把我的例子:PHP和字符str_replace函數

<?php 
$chars_1=array('\',"/","&","¬","~","-","_"); 
$chars_2=array("","","","","","",""); 

$result=str_replace($chars_1,$chars_2,$text); 

?> 

當陣列中把字符\問題it's,因爲我haven't問題休息但如果我把或用\改變其他字符我有問題,我如何可以替換\,並在這種情況下用於替換沒有什麼,如果使用此替換\迷你腳本給我錯誤,如果沒有使用替換\ all ok

Thank's!

回答

1

你必須逃脫斜線,通過使用雙斜線:

$chars_1 = array('\\',"/","&","¬","~","-","_"); 
+0

啊哈完美很不錯:),Thank's! – user2734398