Hi Jeremy

For the number, it didn¹t work

So, I created a new file, simplified with all the tests that semi work, and
don¹t work.

http://allmybookings.com/apilocal/search-results.php?q=restaurants+brussels

The code:

<?php require_once 'JSON.php'; if(isset($_GET['q'])) { $start =
isset($_GET['start']) ? $_GET['start'] : 0; $url =
'http://ajax.googleapis.com/ajax/services/search/local?v=1.0&q='.urlencode($
_GET['q']).'&rsz=small&start='.$start;    $ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);    curl_setopt($ch,
CURLOPT_RETURNTRANSFER, 1);    $body = curl_exec($ch);    curl_close($ch);
$body = json_decode($body);    $i    = 0;    $search_results = array();
foreach($body->responseData->results as $r) {
$search_results['results'][$i]['title'] = $r->title;
$search_results['results'][$i]['phoneNumbers'] = $r->phoneNumbers;
$search_results['results'][$i]['type'] = $r->type;
$search_results['results'][$i]['number'] = $r->number;        $i++;    }
foreach($search_results['results'] as $sr) {             echo
$sr['title']."<br>";        echo count($sr['phoneNumbers'][0])." <- 1 :
gives 1 result. meaning there is 1 phone number<br>"; // best:         echo
count($sr['phoneNumbers']['number'])." <- 2<br>"; // gives 0 results, but
doesn't give an error        echo count($sr['phoneNumbers']['number'][0])."
<- 3<br>"; // gives 0 results, but doesn't give an error        echo
$sr['phoneNumbers']." <- 4<br>"; // doesn't give an error but doesn't give a
number.        echo $sr['phoneNumbers']['number']." <- 5<br>"; // empty line
echo $sr['phoneNumbers']['number'][0]." <- 6<br>"; // empty line // this
gives error     echo count($sr['phoneNumbers'][0]['number'])."<br>"; // this
gives error     echo $sr['phoneNumbers'][0]."<br>"; // this gives error
echo $sr['phoneNumbers'][0]['number']."<br>"; } } ?>


What could it be? ;o)

Thanks again,

Sebastian



On 25/03/09 17:15, "Jeremy Geerdes" <[email protected]> wrote:

> Try $sr['phoneNumbers'][0]['number']
>  
> 
> Jeremy R. Geerdes
> Effective website design & development
> Des Moines, IA
> 
> For more information or a project quote:
> http://jgeerdes.home.mchsi.com
> http://jgeerdes.blogspot.com
> http://jgeerdes.wordpress.com
> [email protected]
> 
> Unless otherwise noted, any price quotes contained within this communication
> are given in US dollars.
> 
> If you're in the Des Moines, IA, area, check out Debra Heights Wesleyan
> Church!
> 
> And check out my blog, Adventures in Web Development, at
> http://jgeerdes.blogspot.com !
> 
>  
> 
> On Mar 25, 2009, at 11:09 AM, sebastian de comocomo wrote:
> 
>> 'http://ajax.googleapis.com/ajax/services/search/local?v=1.0&q='.urlencode($
>> _GET['q']).'&rsz=large&start=
> 
> 
> > 
> 


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google AJAX APIs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/Google-AJAX-Search-API?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to