|
Posted by thecoolone on 12/24/06 08:09
I am trying to implement the yahoo search api using php.
I prefer to use PHP serialized to get the result of the search
displayed.
Right now i get the output like:
Array
(
[ResultSet] => Array
(
[type] => web
[totalResultsAvailable] => 20800000
[totalResultsReturned] => 20
[firstResultPosition] => 1
[moreSearch] =>
/WebSearchService/V1/webSearch?query=bangalore&appid=Jahangir®ion=us
[Result] => Array
(
[0] => Array
(
[Title] => Explocity.com Bangalore. The
city as it happens
[Summary] => Offers an event schedule,
places to see, shopping, dining, and other information about Bangalore.
[Url] =>
http://www.explocity.com/bangalore.asp
[ClickUrl] =>
http://uk.wrs.yahoo.com/_ylt=A0Je5ar3NI5FgPAAtkDdmMwF;_ylu=X3oDMTB2cXVjNTM5BGNvbG8DdwRsA1dTMQRwb3MDMQRzZWMDc3IEdnRpZAM-/SIG=11q4llbq3/EXP=1167033975/**http%3a//www.explocity.com/bangalore.asp
[DisplayUrl] =>
www.explocity.com/bangalore.asp
[ModificationDate] => 1166860800
[MimeType] => text/html
[Cache] => Array
(
[Url] =>
http://uk.wrs.yahoo.com/_ylt=A0Je5ar3NI5FgPAAuEDdmMwF;_ylu=X3oDMTBwOHA5a2tvBGNvbG8DdwRwb3MDMQRzZWMDc3IEdnRpZAM-/SIG=16i81upi9/EXP=1167033975/**http%3a//66.218.69.11/search/cache%3fei=UTF-8%26appid=Jahangir%26query=bangalore%26output=php%26results=20%26u=www.explocity.com/bangalore.asp%26w=bangalore%26d=B-hzWEVuOAIw%26icp=1%26.intl=us
[Size] => 28482
)
)
[1] => Array
(
[Title] => Bangalore
[Summary] => Tourist guide around the city
of Bangalore including historical background, weather, dining,
entertainment, and accommodations.
[Url] => http://www.discoverbangalore.com/
[ClickUrl] =>
http://uk.wrs.yahoo.com/_ylt=A0Je5ar3NI5FgPAAukDdmMwF;_ylu=X3oDMTB2ZjQ4dDExBGNvbG8DdwRsA1dTMQRwb3MDMgRzZWMDc3IEdnRpZAM-/SIG=11ldrk2pv/EXP=1167033975/**http%3a//www.discoverbangalore.com/
[DisplayUrl] => www.discoverbangalore.com/
[ModificationDate] => 1166860800
[MimeType] => text/html
[Cache] => Array
(
[Url] =>
http://uk.wrs.yahoo.com/_ylt=A0Je5ar3NI5FgPAAvEDdmMwF;_ylu=X3oDMTBwZG5hOWwzBGNvbG8DdwRwb3MDMgRzZWMDc3IEdnRpZAM-/SIG=16d2b45uj/EXP=1167033975/**http%3a//66.218.69.11/search/cache%3fei=UTF-8%26appid=Jahangir%26query=bangalore%26output=php%26results=20%26u=www.discoverbangalore.com/%26w=bangalore%26d=BCcdDEVuN_8b%26icp=1%26.intl=us
[Size] => 25882
)
I am trying to format this using 2 foreach loop. One for Array second
for ResultSet and Third for individual Result.
Example of what im trying:
foreach($display as $disp)
{
$output['title']=$disp;
echo "$output";
foreach($disp as $disp2)
{
$newobj=$disp2;
echo "<br>$newobj";
foreach($disp2 as $key=>$value)
{
//$newobj2=$value; // displays [moresearch]
$newobj3=$value[2];
echo "<br>$newobj3";
}}}
But i am having a hard time getting the output that i want.
Can someone help me format the output got from unserialize() in the
same way as yahoo displays its result on its main page.
thanks in advance
Navigation:
[Reply to this message]
|