我有一个 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 和 if 语句的变体,但就是无法得到它。任何帮助将不胜感激。