Hey peps, I'm a bit of a noob a php so please be gentle, The following code is an associated array which takes info form a search engine such as url,title and snippet,
$blekkoArray = array();
$find = array ('http://','https://','www.');
$score = 100;
foreach ($js->RESULT as $item)
{
$blekkoArray[str_replace ($find, '', ($item->{'url'}))] = array(
'title'=> $item->{'url_title'},
'snippet' => $item->{'snippet'},
'score' => $score--
);
}
when I do a print_r this is the output I get
Array ( [example.com] => Array ( [title] => Example title [snippet] => Blah Blah Blah [score] => 100 ) [example2.com] => Array ( [title] => Example title2 [snippet] => Blah Blah Blah2 [score] => 99) [example3.com] => Array ( [title] => Example title3 [snippet] => Blah Blah Blah3 [score] => 98 ) .......)
I'm trying to get an output like the following below
example.com // I would like this to be a href clickable link
Example title
Blah Blah Blah
example.com 2
Example title
Blah Blah Blah 2
and so on, this is the code I've tried
foreach ($js->RESULT as $item)
{
echo "<href={$blekkoArray[str_replace ($find, '', ($item->{'url'}))]}>". $blekkpArray[$key]['title'] . "</a> <br>" .
$blekkoArray[str_replace ($find, '', ($item->{'url'}))] . "<br>" . $blekkoArray[$key]['snippet'];
echo "<br>"; echo "<br>";
}
but when I run the code I'm getting undifined index and undifined variable warnings, can anyone help please