php - I need to fetch address against postcodes -


i have database of postcodes need fetach address against each postcode google or other service, can please suggest me ?

what you're after called "geocoding."

google maps provides service, can read documentation on how use google developer page it:

https://developers.google.com/maps/documentation/geocoding/


you're able call api information on address, here example getting information melbourne, australia (postcode 3000):

https://maps.googleapis.com/maps/api/geocode/json?address=3000,australia


you're going need fetch url each postcode you're looking , run json_decode on result. after can extract information want it.

here's quick example whipped up:

<?php  // geocode information function address_geocode_json($address) {     $geocode_url = 'http://maps.googleapis.com/maps/api/geocode/json?address=' . urlencode($address);      $ch = curl_init();     curl_setopt($ch, curlopt_url, $geocode_url);     curl_setopt($ch, curlopt_returntransfer, 1);     curl_setopt($ch, curlopt_connecttimeout, 5);     $content = curl_exec($ch);     curl_close($ch);      $result = ( $content ? json_decode( $content ) : false );      return ( isset( $result->results ) ? $result->results : false ); }  // postcode information-- use within loop $postcode_information = address_geocode_json( '3000, australia' );  // here result structure var_dump( $postcode_information ); 

Comments