我有一個preg_match_all從一個字符串中生成一個url數組。數組類似於:在數組中搜索並替換它的一些值
$url[0] = "http://www.siteone.com";
$url[1] = "http://www.sitetwo.com";
$url[2] = "http://www.sitethree.com/example1";
$url[3] = "http://www.sitefour.com";
$url[4] = "http://www.sitethree.com/example2";
$url[5] = "http://www.sitefive";
$url[6] = "http://www.sitesix";
$url[7] = "http://www.siteseven";
$url[8] = "http://www.sitethree.com/example3";
不過,我需要能夠通過#URL陣列搜索更改值時,它包含「http://www.sitethree.com」,並設置在這個特定的值數組爲「沒有價值」。因此,一旦應用此過程,,將數組是這樣的:
$url[0] = "http://www.siteone.com";
$url[1] = "http://www.sitetwo.com";
$url[2] = "no value";
$url[3] = "http://www.sitefour.com";
$url[4] = "no value";
$url[5] = "http://www.sitefive";
$url[6] = "http://www.sitesix";
$url[7] = "http://www.siteseven";
$url[8] = "no value";
我試圖preg_match_all的許多變化,如果循環中的語句,但只是無法得到它。任何幫助將不勝感激。
偉大的作品,謝謝。 –
@Aran歡迎:) –