以下代码是一个关联数组,它从搜索引擎获取信息,例如 url、title 和 snippet,
$googleArray = array();
$find = array ('http://','https://','www.');
$score = 100;
foreach ($all_items as $item) //
{
$googleArray[str_replace ($find, '', ($item->{'link'}))] = array(
'title'=> $item->{'title'},
'snippet' => $item->{'snippet'},
'score' => $score--
);
}
我知道想在网页上用 html 打印出来,我试过这段代码。
foreach ($all_items as $item)
{
echo "<href={$googleArray[($item->{'link'})]}>". $googleArray['title'] . "</a> <br>" .
$googleArray['link'] . "<br>" . $googleArray['snippet'];
echo "<br>"; echo "<br>";
}
这些是我得到的错误
Notice: Undefined index: http://www.time.com/
Notice: Undefined index: title
Notice: Undefined index: link
Notice: Undefined index: snippet
谁能看到我哪里出错了