這是迄今爲止我所編寫的代碼:如何從一個數組中刪除值?
foreach ($link_body as $key => $unfinished_link)
{
#further Remove non ad links
if (stristr($unfinished_link, "inactive" OR "nofollow") === TRUE)
{
unset($link_body[$key]);
}
echo "<font color='#FFFFFF' size='16'>$unfinished_link</font><br>";
}
我沒有收到任何錯誤消息,但我一直得到的結果是這樣的:
/cars/" />
/cars/">
/cars/" class="inactive">(not what I wanted)
/cars/" class="inactive">(not what I wanted)
/cars/" class="inactive">(not what I wanted)
/cars/" rel="nofollow">(not what I wanted)
/cars/?layout=gallery" rel="nofollow">(not what I wanted)
/cars/2001-ford-escort-great-condition/1235588">(IS what I wanted)
我在哪裏搞亂了這裏球員? THX
' 「無效」 或「nofollow的「 - 這個。你不能這樣做。 – naththedeveloper 2014-10-31 08:47:17
你需要做的'如果(stristr($ unfinished_link, 「不活動」)|| stristr($ unfinished_link, 「nofollow的」)){...}' – naththedeveloper 2014-10-31 08:48:06
我已刪除OR和剛剛離開的 「無效」 .. .still得到同樣的結果 – tommyg 2014-10-31 08:49:32