我有一個文本文件,我提取了所有域地址與http://
現在我想要替換所有http://
。在我的比賽陣列「」但是什麼也沒有發生IM甚至沒有得到一個錯誤從未運行「preg_replace()」無法正常工作。
$list = file_get_contents('file.txt');
preg_match_all("/http:\/\/.([a-z]{1,24}).([a-z^0-9-]{1,23}).([a-z]{1,3})/", $list, $matches);
for ($i=0; $i>=50; $i++) {
$pattern = array();
$replacement = array();
$pattern[0][$i] = "/http:\/\/.[w-w]{1,3}/";
$replacement[0][$i] = '';
preg_replace($pattern[0][$i], $replacement[0][$i], $matches[0][$i]);
}
print_r($matches);
你能告訴我們你的輸入「file.txt」嗎? – Helpful
你確定你的循環條件正確嗎?對於($ i = 0; $ i> = 50; $ i ++){'是一個非操作對象,這個循環從不執行 – Ibrahim
'。 – Toto