{"id":699,"date":"2015-08-04T19:09:41","date_gmt":"2015-08-04T19:09:41","guid":{"rendered":"https:\/\/www.codexworld.com\/?p=699"},"modified":"2024-06-27T06:57:53","modified_gmt":"2024-06-27T06:57:53","slug":"get-zipcode-from-address-using-google-maps-api-php","status":"publish","type":"post","link":"https:\/\/www.codexworld.com\/get-zipcode-from-address-using-google-maps-api-php\/","title":{"rendered":"Get Zipcode from Address using Google Maps API and PHP"},"content":{"rendered":"<p>A zip code or postal code makes an address more accurate and helps to know the correct location. There are many online services available to get zipcodes by address. But if you want to get the zipcode from address dynamically, an API service needs to be used.<\/p>\n<p>For some specific cases of the web application, we need to retrieve zipcode from address dynamically. You can extract postal code from address with Google Maps Geocoding API using PHP. In this tutorial, we will show you how to <b>get zipcode from address<\/b> using Geocoding API and PHP.<\/p>\n<h2>Google Maps API Key<\/h2>\n<p>The Google Maps API Key is required to post request to Geocoding API and get response. Before getting started to extract zipcode from address, create an API key on the Google Cloud console.<\/p>\n<ul>\n<li>Go to the <a href=\"https:\/\/console.cloud.google.com\/\" target=\"_blank\" rel=\"noopener\">Google Cloud console<\/a>.<\/li>\n<li>Select the project from the Project drop-down menu at the top. If you don&#8217;t have an existing project, create a new one.<\/li>\n<li>In the left navigation pane, select the <b>APIs &amp; Services<\/b> &raquo; <b>Credentials<\/b>.<\/li>\n<li>In the Credentials page, select <b>CREATE CREDENTIALS<\/b> &raquo; <b>API key<\/b>.<\/li>\n<li>The API key will be created and a dialog will appear with the newly created API key.<\/li>\n<li>Navigate to the Library page from the left menu panel and make sure the <b>Geocoding API<\/b> is enabled.<\/li>\n<\/ul>\n<p>Copy this API key for later use in the script on the Google Maps Geocoding API request.<\/p>\n<h2>Get Zipcode from Address using PHP<\/h2>\n<p>The following example code shows steps to find zipcode from a given address using Google Geocoding API and PHP.<\/p>\n<ul>\n<li>Set the required parameter in the defined variables.\n<ul>\n<li><code>$GOOGLE_API_KEY<\/code> &#8211; Specify the Google API Key.<\/li>\n<li><code>$address<\/code> &#8211; Specify the address from which you want to get postal code.<\/li>\n<\/ul>\n<\/li>\n<li>Format the address by replacing the blank space with a plus sign (+).<\/li>\n<li>Request Geocoding API (<code>https:\/\/maps.googleapis.com\/maps\/api\/geocode\/json<\/code>) using the file_get_contents() method in PHP.<\/li>\n<li>Pass <code>address<\/code> and <code>key<\/code> parameters in the Geocoding API URL as query string.<\/li>\n<li>Decode JSON response returned by the Geocoding API using <b>PHP json_decode()<\/b> function.<\/li>\n<li>Get <code>postal_code<\/code> from the <code>address_components<\/code> object of API response.<\/li>\n<\/ul>\n<pre><span style=\"color: #0000BB\">&lt;?php <br \/> <br \/><\/span><span style=\"color: #FF8000\">\/\/&nbsp;Google&nbsp;Maps&nbsp;API&nbsp;Key <br \/><\/span><span style=\"color: #0000BB\">$GOOGLE_API_KEY&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #DD0000\">'YOUR_API_KEY_HERE'<\/span><span style=\"color: #007700\">; <br \/> <br \/><\/span><span style=\"color: #FF8000\">\/\/&nbsp;Address&nbsp;from&nbsp;which&nbsp;the&nbsp;zipcode&nbsp;will&nbsp;be&nbsp;retrieved <br \/><\/span><span style=\"color: #0000BB\">$address&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #DD0000\">'White&nbsp;House,&nbsp;Pennsylvania&nbsp;Avenue&nbsp;Northwest,&nbsp;Washington,&nbsp;United&nbsp;States'<\/span><span style=\"color: #007700\">; <br \/> <br \/><\/span><span style=\"color: #FF8000\">\/\/&nbsp;Formatted&nbsp;address <br \/><\/span><span style=\"color: #0000BB\">$address_fmt&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">str_replace<\/span><span style=\"color: #007700\">(array(<\/span><span style=\"color: #DD0000\">'&nbsp;'<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #DD0000\">'&amp;'<\/span><span style=\"color: #007700\">),&nbsp;<\/span><span style=\"color: #DD0000\">'+'<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #0000BB\">$address<\/span><span style=\"color: #007700\">); <br \/> <br \/><\/span><span style=\"color: #FF8000\">\/\/&nbsp;Get&nbsp;geo&nbsp;data&nbsp;from&nbsp;Google&nbsp;Maps&nbsp;API&nbsp;by&nbsp;address <br \/><\/span><span style=\"color: #0000BB\">$geodataFromAddr&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">file_get_contents<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #DD0000\">\"https:\/\/maps.googleapis.com\/maps\/api\/geocode\/json?address=<\/span><span style=\"color: #007700\">{<\/span><span style=\"color: #0000BB\">$address_fmt<\/span><span style=\"color: #007700\">}<\/span><span style=\"color: #DD0000\">&amp;key=<\/span><span style=\"color: #007700\">{<\/span><span style=\"color: #0000BB\">$GOOGLE_API_KEY<\/span><span style=\"color: #007700\">}<\/span><span style=\"color: #DD0000\">\"<\/span><span style=\"color: #007700\">); <br \/> <br \/><\/span><span style=\"color: #FF8000\">\/\/&nbsp;Decode&nbsp;JSON&nbsp;data&nbsp;returned&nbsp;by&nbsp;API <br \/><\/span><span style=\"color: #0000BB\">$apiResponse&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">json_decode<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">$geodataFromAddr<\/span><span style=\"color: #007700\">); <br \/> <br \/>if(!empty(<\/span><span style=\"color: #0000BB\">$apiResponse<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">error_message<\/span><span style=\"color: #007700\">)){&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;die(<\/span><span style=\"color: #DD0000\">\"API&nbsp;Error:&nbsp;\"<\/span><span style=\"color: #007700\">.<\/span><span style=\"color: #0000BB\">$apiResponse<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">error_message<\/span><span style=\"color: #007700\">);&nbsp; <br \/>} <br \/> <br \/>if(!empty(<\/span><span style=\"color: #0000BB\">$apiResponse<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">results<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #0000BB\">0<\/span><span style=\"color: #007700\">])){ <br \/>&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #FF8000\">\/\/&nbsp;Retrieve&nbsp;latitude&nbsp;and&nbsp;longitude&nbsp;from&nbsp;API&nbsp;data <br \/>&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$latitude&nbsp;&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">$apiResponse<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">results<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #0000BB\">0<\/span><span style=\"color: #007700\">]-&gt;<\/span><span style=\"color: #0000BB\">geometry<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">location<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">lat<\/span><span style=\"color: #007700\">;&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$longitude&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">$apiResponse<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">results<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #0000BB\">0<\/span><span style=\"color: #007700\">]-&gt;<\/span><span style=\"color: #0000BB\">geometry<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">location<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">lng<\/span><span style=\"color: #007700\">; <br \/> <br \/>&nbsp;&nbsp;&nbsp;&nbsp;if(!empty(<\/span><span style=\"color: #0000BB\">$latitude<\/span><span style=\"color: #007700\">)&nbsp;&amp;&amp;&nbsp;!empty(<\/span><span style=\"color: #0000BB\">$longitude<\/span><span style=\"color: #007700\">)){ <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #FF8000\">\/\/&nbsp;Get&nbsp;geo&nbsp;data&nbsp;from&nbsp;Google&nbsp;Maps&nbsp;API&nbsp;by&nbsp;latlng <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$geodataFromLatLon&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">file_get_contents<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #DD0000\">\"https:\/\/maps.googleapis.com\/maps\/api\/geocode\/json?latlng=<\/span><span style=\"color: #007700\">{<\/span><span style=\"color: #0000BB\">$latitude<\/span><span style=\"color: #007700\">}<\/span><span style=\"color: #DD0000\">,<\/span><span style=\"color: #007700\">{<\/span><span style=\"color: #0000BB\">$longitude<\/span><span style=\"color: #007700\">}<\/span><span style=\"color: #DD0000\">&amp;key=<\/span><span style=\"color: #007700\">{<\/span><span style=\"color: #0000BB\">$GOOGLE_API_KEY<\/span><span style=\"color: #007700\">}<\/span><span style=\"color: #DD0000\">\"<\/span><span style=\"color: #007700\">); <br \/> <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #FF8000\">\/\/&nbsp;Decode&nbsp;JSON&nbsp;data&nbsp;returned&nbsp;by&nbsp;API <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$apiResponse&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">json_decode<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">$geodataFromLatLon<\/span><span style=\"color: #007700\">); <br \/> <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if(!empty(<\/span><span style=\"color: #0000BB\">$apiResponse<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">error_message<\/span><span style=\"color: #007700\">)){&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;die(<\/span><span style=\"color: #DD0000\">\"API&nbsp;Error:&nbsp;\"<\/span><span style=\"color: #007700\">.<\/span><span style=\"color: #0000BB\">$apiResponse<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">error_message<\/span><span style=\"color: #007700\">);&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;} <br \/> <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if(!empty(<\/span><span style=\"color: #0000BB\">$apiResponse<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">results<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #0000BB\">0<\/span><span style=\"color: #007700\">])){ <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$address_components&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">$apiResponse<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">results<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #0000BB\">0<\/span><span style=\"color: #007700\">]-&gt;<\/span><span style=\"color: #0000BB\">address_components<\/span><span style=\"color: #007700\">; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;foreach(<\/span><span style=\"color: #0000BB\">$address_components&nbsp;<\/span><span style=\"color: #007700\">as&nbsp;<\/span><span style=\"color: #0000BB\">$acp_row<\/span><span style=\"color: #007700\">){ <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if(<\/span><span style=\"color: #0000BB\">$acp_row<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">types<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #0000BB\">0<\/span><span style=\"color: #007700\">]&nbsp;==&nbsp;<\/span><span style=\"color: #DD0000\">'postal_code'<\/span><span style=\"color: #007700\">){ <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$postal_code&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">$acp_row<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">long_name<\/span><span style=\"color: #007700\">; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;} <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;} <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;} <br \/>&nbsp;&nbsp;&nbsp;&nbsp;} <br \/>} <br \/> <br \/><\/span><span style=\"color: #0000BB\">?&gt;<\/span><\/pre>\n<p>Display zipcode of the given address on the web page.<\/p>\n<pre><span style=\"color: #FF8000\">\/\/&nbsp;Render&nbsp;the&nbsp;zipcode&nbsp;of&nbsp;the&nbsp;given&nbsp;address <br \/><\/span><span style=\"color: #007700\">echo&nbsp;<\/span><span style=\"color: #DD0000\">'Zipcode:&nbsp;'<\/span><span style=\"color: #007700\">.<\/span><span style=\"color: #0000BB\">$postal_code<\/span><span style=\"color: #007700\">;<\/span><\/pre>\n<p class=\"seeAlso\"><span><\/span><a href=\"https:\/\/www.codexworld.com\/get-latitude-longitude-from-address-using-google-maps-api-php\/\">Get Latitude and Longitude from Address using PHP<\/a><\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>A zip code or postal code makes an address more accurate and helps to know the correct location. There are many online services available to get zipcodes by address. But if you want to get <\/p>\n","protected":false},"author":1,"featured_media":5676,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[4],"tags":[250,380,13,15,35,14],"class_list":["post-699","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-php","tag-api","tag-geocoding","tag-google-api","tag-google-maps","tag-google-maps-api","tag-php","cat-4-id","has_thumb"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Get Zipcode from Address using Google Maps API and PHP - CodexWorld<\/title>\n<meta name=\"description\" content=\"Find postal code from address using PHP - Example code snippet to get zipcode from address with Google Maps Geocoding API using PHP.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.codexworld.com\/get-zipcode-from-address-using-google-maps-api-php\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Get Zipcode from Address using Google Maps API and PHP - CodexWorld\" \/>\n<meta property=\"og:description\" content=\"Find postal code from address using PHP - Example code snippet to get zipcode from address with Google Maps Geocoding API using PHP.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.codexworld.com\/get-zipcode-from-address-using-google-maps-api-php\/\" \/>\n<meta property=\"og:site_name\" content=\"CodexWorld\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/codexworld\" \/>\n<meta property=\"article:author\" content=\"https:\/\/www.facebook.com\/codexworld\" \/>\n<meta property=\"article:published_time\" content=\"2015-08-04T19:09:41+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-06-27T06:57:53+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.codexworld.com\/wp-content\/uploads\/2015\/08\/get-zipcode-from-address-using-google-maps-geocoding-api-php-codexworld.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1920\" \/>\n\t<meta property=\"og:image:height\" content=\"1080\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"CodexWorld\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@codexworldblog\" \/>\n<meta name=\"twitter:site\" content=\"@codexworldweb\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"CodexWorld\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/get-zipcode-from-address-using-google-maps-api-php\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/get-zipcode-from-address-using-google-maps-api-php\\\/\"},\"author\":{\"name\":\"CodexWorld\",\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/#\\\/schema\\\/person\\\/9da51d8fa3cdefeb5ec9c69136d4baf0\"},\"headline\":\"Get Zipcode from Address using Google Maps API and PHP\",\"datePublished\":\"2015-08-04T19:09:41+00:00\",\"dateModified\":\"2024-06-27T06:57:53+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/get-zipcode-from-address-using-google-maps-api-php\\\/\"},\"wordCount\":368,\"commentCount\":4,\"publisher\":{\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/get-zipcode-from-address-using-google-maps-api-php\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.codexworld.com\\\/wp-content\\\/uploads\\\/2015\\\/08\\\/get-zipcode-from-address-using-google-maps-geocoding-api-php-codexworld.png\",\"keywords\":[\"API\",\"Geocoding\",\"Google API\",\"Google Maps\",\"Google Maps API\",\"PHP\"],\"articleSection\":[\"PHP\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.codexworld.com\\\/get-zipcode-from-address-using-google-maps-api-php\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/get-zipcode-from-address-using-google-maps-api-php\\\/\",\"url\":\"https:\\\/\\\/www.codexworld.com\\\/get-zipcode-from-address-using-google-maps-api-php\\\/\",\"name\":\"Get Zipcode from Address using Google Maps API and PHP - CodexWorld\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/get-zipcode-from-address-using-google-maps-api-php\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/get-zipcode-from-address-using-google-maps-api-php\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.codexworld.com\\\/wp-content\\\/uploads\\\/2015\\\/08\\\/get-zipcode-from-address-using-google-maps-geocoding-api-php-codexworld.png\",\"datePublished\":\"2015-08-04T19:09:41+00:00\",\"dateModified\":\"2024-06-27T06:57:53+00:00\",\"description\":\"Find postal code from address using PHP - Example code snippet to get zipcode from address with Google Maps Geocoding API using PHP.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/get-zipcode-from-address-using-google-maps-api-php\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.codexworld.com\\\/get-zipcode-from-address-using-google-maps-api-php\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/get-zipcode-from-address-using-google-maps-api-php\\\/#primaryimage\",\"url\":\"https:\\\/\\\/www.codexworld.com\\\/wp-content\\\/uploads\\\/2015\\\/08\\\/get-zipcode-from-address-using-google-maps-geocoding-api-php-codexworld.png\",\"contentUrl\":\"https:\\\/\\\/www.codexworld.com\\\/wp-content\\\/uploads\\\/2015\\\/08\\\/get-zipcode-from-address-using-google-maps-geocoding-api-php-codexworld.png\",\"width\":1920,\"height\":1080,\"caption\":\"get-zipcode-from-address-using-google-maps-geocoding-api-php-codexworld\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/get-zipcode-from-address-using-google-maps-api-php\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.codexworld.com\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Get Zipcode from Address using Google Maps API and PHP\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/#website\",\"url\":\"https:\\\/\\\/www.codexworld.com\\\/\",\"name\":\"CodexWorld\",\"description\":\"Web &amp; Mobile App Development Company\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.codexworld.com\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/#organization\",\"name\":\"CodexWorld\",\"url\":\"https:\\\/\\\/www.codexworld.com\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.codexworld.com\\\/wp-content\\\/uploads\\\/2014\\\/09\\\/codexworld-logo.png\",\"contentUrl\":\"https:\\\/\\\/www.codexworld.com\\\/wp-content\\\/uploads\\\/2014\\\/09\\\/codexworld-logo.png\",\"width\":200,\"height\":19,\"caption\":\"CodexWorld\"},\"image\":{\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/codexworld\",\"https:\\\/\\\/x.com\\\/codexworldweb\",\"https:\\\/\\\/www.linkedin.com\\\/company\\\/codexworld\",\"https:\\\/\\\/www.youtube.com\\\/codexworld\"]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/#\\\/schema\\\/person\\\/9da51d8fa3cdefeb5ec9c69136d4baf0\",\"name\":\"CodexWorld\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/cf4999db3b409de559f80677afa01729bb2eeda19be273c254e8b2c22729e386?s=96&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/cf4999db3b409de559f80677afa01729bb2eeda19be273c254e8b2c22729e386?s=96&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/cf4999db3b409de559f80677afa01729bb2eeda19be273c254e8b2c22729e386?s=96&r=g\",\"caption\":\"CodexWorld\"},\"description\":\"CodexWorld is a programming blog, one-stop destination for web professionals \u2014 developers, programmers, freelancers, and site owners.\",\"sameAs\":[\"http:\\\/\\\/www.codexworld.com\",\"https:\\\/\\\/www.facebook.com\\\/codexworld\",\"https:\\\/\\\/x.com\\\/codexworldblog\"],\"url\":\"https:\\\/\\\/www.codexworld.com\\\/author\\\/nitya192265\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Get Zipcode from Address using Google Maps API and PHP - CodexWorld","description":"Find postal code from address using PHP - Example code snippet to get zipcode from address with Google Maps Geocoding API using PHP.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.codexworld.com\/get-zipcode-from-address-using-google-maps-api-php\/","og_locale":"en_US","og_type":"article","og_title":"Get Zipcode from Address using Google Maps API and PHP - CodexWorld","og_description":"Find postal code from address using PHP - Example code snippet to get zipcode from address with Google Maps Geocoding API using PHP.","og_url":"https:\/\/www.codexworld.com\/get-zipcode-from-address-using-google-maps-api-php\/","og_site_name":"CodexWorld","article_publisher":"https:\/\/www.facebook.com\/codexworld","article_author":"https:\/\/www.facebook.com\/codexworld","article_published_time":"2015-08-04T19:09:41+00:00","article_modified_time":"2024-06-27T06:57:53+00:00","og_image":[{"width":1920,"height":1080,"url":"https:\/\/www.codexworld.com\/wp-content\/uploads\/2015\/08\/get-zipcode-from-address-using-google-maps-geocoding-api-php-codexworld.png","type":"image\/png"}],"author":"CodexWorld","twitter_card":"summary_large_image","twitter_creator":"@codexworldblog","twitter_site":"@codexworldweb","twitter_misc":{"Written by":"CodexWorld","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.codexworld.com\/get-zipcode-from-address-using-google-maps-api-php\/#article","isPartOf":{"@id":"https:\/\/www.codexworld.com\/get-zipcode-from-address-using-google-maps-api-php\/"},"author":{"name":"CodexWorld","@id":"https:\/\/www.codexworld.com\/#\/schema\/person\/9da51d8fa3cdefeb5ec9c69136d4baf0"},"headline":"Get Zipcode from Address using Google Maps API and PHP","datePublished":"2015-08-04T19:09:41+00:00","dateModified":"2024-06-27T06:57:53+00:00","mainEntityOfPage":{"@id":"https:\/\/www.codexworld.com\/get-zipcode-from-address-using-google-maps-api-php\/"},"wordCount":368,"commentCount":4,"publisher":{"@id":"https:\/\/www.codexworld.com\/#organization"},"image":{"@id":"https:\/\/www.codexworld.com\/get-zipcode-from-address-using-google-maps-api-php\/#primaryimage"},"thumbnailUrl":"https:\/\/www.codexworld.com\/wp-content\/uploads\/2015\/08\/get-zipcode-from-address-using-google-maps-geocoding-api-php-codexworld.png","keywords":["API","Geocoding","Google API","Google Maps","Google Maps API","PHP"],"articleSection":["PHP"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.codexworld.com\/get-zipcode-from-address-using-google-maps-api-php\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.codexworld.com\/get-zipcode-from-address-using-google-maps-api-php\/","url":"https:\/\/www.codexworld.com\/get-zipcode-from-address-using-google-maps-api-php\/","name":"Get Zipcode from Address using Google Maps API and PHP - CodexWorld","isPartOf":{"@id":"https:\/\/www.codexworld.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.codexworld.com\/get-zipcode-from-address-using-google-maps-api-php\/#primaryimage"},"image":{"@id":"https:\/\/www.codexworld.com\/get-zipcode-from-address-using-google-maps-api-php\/#primaryimage"},"thumbnailUrl":"https:\/\/www.codexworld.com\/wp-content\/uploads\/2015\/08\/get-zipcode-from-address-using-google-maps-geocoding-api-php-codexworld.png","datePublished":"2015-08-04T19:09:41+00:00","dateModified":"2024-06-27T06:57:53+00:00","description":"Find postal code from address using PHP - Example code snippet to get zipcode from address with Google Maps Geocoding API using PHP.","breadcrumb":{"@id":"https:\/\/www.codexworld.com\/get-zipcode-from-address-using-google-maps-api-php\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.codexworld.com\/get-zipcode-from-address-using-google-maps-api-php\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.codexworld.com\/get-zipcode-from-address-using-google-maps-api-php\/#primaryimage","url":"https:\/\/www.codexworld.com\/wp-content\/uploads\/2015\/08\/get-zipcode-from-address-using-google-maps-geocoding-api-php-codexworld.png","contentUrl":"https:\/\/www.codexworld.com\/wp-content\/uploads\/2015\/08\/get-zipcode-from-address-using-google-maps-geocoding-api-php-codexworld.png","width":1920,"height":1080,"caption":"get-zipcode-from-address-using-google-maps-geocoding-api-php-codexworld"},{"@type":"BreadcrumbList","@id":"https:\/\/www.codexworld.com\/get-zipcode-from-address-using-google-maps-api-php\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.codexworld.com\/"},{"@type":"ListItem","position":2,"name":"Get Zipcode from Address using Google Maps API and PHP"}]},{"@type":"WebSite","@id":"https:\/\/www.codexworld.com\/#website","url":"https:\/\/www.codexworld.com\/","name":"CodexWorld","description":"Web &amp; Mobile App Development Company","publisher":{"@id":"https:\/\/www.codexworld.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.codexworld.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.codexworld.com\/#organization","name":"CodexWorld","url":"https:\/\/www.codexworld.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.codexworld.com\/#\/schema\/logo\/image\/","url":"https:\/\/www.codexworld.com\/wp-content\/uploads\/2014\/09\/codexworld-logo.png","contentUrl":"https:\/\/www.codexworld.com\/wp-content\/uploads\/2014\/09\/codexworld-logo.png","width":200,"height":19,"caption":"CodexWorld"},"image":{"@id":"https:\/\/www.codexworld.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/codexworld","https:\/\/x.com\/codexworldweb","https:\/\/www.linkedin.com\/company\/codexworld","https:\/\/www.youtube.com\/codexworld"]},{"@type":"Person","@id":"https:\/\/www.codexworld.com\/#\/schema\/person\/9da51d8fa3cdefeb5ec9c69136d4baf0","name":"CodexWorld","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/cf4999db3b409de559f80677afa01729bb2eeda19be273c254e8b2c22729e386?s=96&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/cf4999db3b409de559f80677afa01729bb2eeda19be273c254e8b2c22729e386?s=96&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/cf4999db3b409de559f80677afa01729bb2eeda19be273c254e8b2c22729e386?s=96&r=g","caption":"CodexWorld"},"description":"CodexWorld is a programming blog, one-stop destination for web professionals \u2014 developers, programmers, freelancers, and site owners.","sameAs":["http:\/\/www.codexworld.com","https:\/\/www.facebook.com\/codexworld","https:\/\/x.com\/codexworldblog"],"url":"https:\/\/www.codexworld.com\/author\/nitya192265\/"}]}},"jetpack_publicize_connections":[],"jetpack_featured_media_url":"https:\/\/www.codexworld.com\/wp-content\/uploads\/2015\/08\/get-zipcode-from-address-using-google-maps-geocoding-api-php-codexworld.png","jetpack_shortlink":"https:\/\/wp.me\/p6bxIh-bh","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.codexworld.com\/wp-json\/wp\/v2\/posts\/699","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.codexworld.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.codexworld.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.codexworld.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.codexworld.com\/wp-json\/wp\/v2\/comments?post=699"}],"version-history":[{"count":5,"href":"https:\/\/www.codexworld.com\/wp-json\/wp\/v2\/posts\/699\/revisions"}],"predecessor-version":[{"id":5677,"href":"https:\/\/www.codexworld.com\/wp-json\/wp\/v2\/posts\/699\/revisions\/5677"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.codexworld.com\/wp-json\/wp\/v2\/media\/5676"}],"wp:attachment":[{"href":"https:\/\/www.codexworld.com\/wp-json\/wp\/v2\/media?parent=699"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.codexworld.com\/wp-json\/wp\/v2\/categories?post=699"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.codexworld.com\/wp-json\/wp\/v2\/tags?post=699"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}