開頭我有一個值的數組。如果數組的值以
我的爬蟲掃描網頁並插入所有鏈接,鏈接的標題和描述是一個多維數組。
但現在我有一個新的數組,我只想鏈接,說明和標題等,如果他們有任何價值開始在陣列中($ bbc_values)
但我真的不知道該怎麼辦這個。在實際的代碼方面,我已經得到了很多,但任何人都可以給我任何想法a)爲什麼我的代碼不工作b)對於我的問題的建議?
$bbc_values = array('http://www.bbc.co.uk/news/health-', 'http://www.bbc.co.uk/news/politics-', 'http://www.bbc.co.uk/news/uk-', 'http://www.bbc.co.uk/news/technology-', 'http://www.bbc.co.uk/news/england-', 'http://www.bbc.co.uk/news/northern_ireland-', 'http://www.bbc.co.uk/news/scotland-', 'http://www.bbc.co.uk/news/wales-', 'http://www.bbc.co.uk/news/business-', 'http://www.bbc.co.uk/news/education-', 'http://www.bbc.co.uk/news/science_and_enviroment-', 'http://www.bbc.co.uk/news/entertainment_and_arts-', 'http://edition.cnn.com/');
foreach ($links as $link) {
$output = array(
"title" => Titles($link), //dont know what Titles is, variable or string?
"description" => getMetas($link),
"keywords" => getKeywords($link),
"link" => $link
);
if (empty($output["description"])) {
$output["description"] = getWord($link);
}
}
$data = implode(" , ", $output['link']);
foreach ($output as $new_array) {
if (in_array($output, $bbc_values)) {
$news_stories[] = $new_array;
}
var_dump($news_stories);
}
請在下次使用「添加評論」來討論您的疑惑。答案只能用於提供......好的答案。 –
他不會在他的rep –