php - Printing for a combined array to html -


i have 3 arrays print out in nice html format search engines, here foreach loops printing out

bing api

foreach($jsonobj->d->results $value){             echo  "<a href=\"{$value->url}\">{$value->title}</a><p>{$value->description}</p>". "<br>";          } 

blekko api

foreach($js->result $item){         echo  "<a href=\"{$item->url}\">{$item->url_title}</a><p>{$item->snippet}</p>". "<br>";      } 

google api

foreach($all_items $item){         echo  "<a href=\"{$item->link}\">{$item->title}</a><p>{$item->snippet}</p>". "<br>";      } 

i created comnined array such below

$combined = array();   foreach($bingarray $key=>$value){  if(isset($combined[$key])) $combined[$key]["score"] += $value['score'];    else     $combined[$key] = array("score"=>$value['score'],"title"=>$value["title"], "snippet"=>$value   ["snippet"]);  } 

when print_r($combined) following output

array ( [example.com] => array ( [score] => 51 [title] => example title[snippet] => blah baly... )[example2.com] => array ( [score] => 45 [title] => example title2[snippet] => blah baly2... ) ....)  

this fine , same format 3 api arrays, i'm trying print out combined array in html 3 api's , here code tried

foreach($combined $value){             echo  "<a href=\"{$value->url}\">{$value->title}</a><p>{$value->snippet}</p>". "<br>";              } 

but when run error "trying property of non-object", suspect need change somthing in here "foreach($combined $value)" not sure what, can help

this because not have objects anymore.

change this:

foreach($combined $value){     echo "<a href=\"{$value->url}\">{$value->title}</a><p>{$value->snippet}</p>". "<br>"; } 

to this:

foreach($combined $url => $value){     echo "<a href=\"{$url}\">{$value['title']}</a><p>{$value['snippet']}</p>". "<br>"; } 

Comments

Popular posts from this blog

c++ - Creating new partition disk winapi -

Android Prevent Bluetooth Pairing Dialog -

php - joomla get content in onBeforeCompileHead function -