0

Possible Duplicate:
Extract JSONP Resultset in PHP

    $url_address = "http://geocoder.ca/?latt=" . $lat . "&longt=" . $lon . "&reverse=1&allna=1&geoit=xml&corner=1&jsonp=1&callback=getinfo";
    $addressSet = json_decode(file_get_contents($url_address), true);

When I try to to access $addressSet[0] is does not have anything

So the http://geocoder.ca/?latt=42.04&longt=-87.79&reverse=1&allna=1&geoit=xml&corner=1&jsonp=1&callback=getinfo returns data, how can I parse it?

Community
  • 1
  • 1
Andrew
  • 7,619
  • 13
  • 63
  • 117
  • 1
    You need a regex to extract the JSON first, then process it further. (PHP "parses" it, btw, you just "traverse" the resulting array strucutre.) – mario Nov 24 '12 at 21:48

1 Answers1

1

It's not returning JSON, it's returning JSONP. Unfortunately geocoder.ca doesn't have a plain JSON API.

The real question is how to parse JSONP with PHP. See this answer to Extract JSONP Resultset in PHP

Community
  • 1
  • 1
bradley.ayers
  • 37,165
  • 14
  • 93
  • 99