开头我有一个值的数组。如果数组的值以
我的爬虫扫描网页并插入所有链接,链接的标题和描述是一个多维数组。
但现在我有一个新的数组,我只想链接,说明和标题等,如果他们有任何价值开始在阵列中($ 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 –