我有一個包含電子郵件更換損壞的電子郵件地址,使用PHP
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
@domain.com
[email protected]
[email protected]
我需要從列表中刪除@ domain.com列表的文件file.txt的。我使用此代碼:
file_put_contents('file.txt',
str_replace("@domain.com","",file_get_contents('file.txt')));
但是,這也將刪除[email protected]
@domain.com
,使其成爲一個不正確的列表。
我該怎麼做?
感謝您的開頭! ereg_replace也不錯? – gr68 2014-12-05 14:37:53
您可以使用該方法。但似乎這種方法已被廢棄(如http://php.net/manual/en/function.ereg-replace.php中所述)。所以最好使用preg_replace(或preg_replace_all) – 2014-12-05 14:39:25
你必須逃避點,因爲它意味着任何字符。 – Toto 2014-12-05 15:12:56