title: Google Places API Web Service (PHP): how to get 'administrative_area_2 place_id' for a given 'place_id'
body: <p>My webapp receives a place_id for a user-selected geo. For example: if the user chooses on the frontend a <a href="https://en.wikipedia.org/wiki/Comacchio" rel="nofollow">place called "Comacchio"</a> (it's a town, part of the <em>administrative_area_level_2</em> called <a href="https://en.wikipedia.org/wiki/Province_of_Ferrara" rel="nofollow">Province of Ferrara</a>) my webapp recives the place_id for Comacchio: <code>ChIJ0yHebbB1fkcR7YujotES0dA</code>.</p>
  
  <p>When I query maps.googleapis.com for said place_id, I get a whole lot of information (see below) but not the one I need: <strong>what I need is the place_id for the administrative_area_level_2</strong> of the input place_id (which would be <code>ChIJ7y4rEyxCfkcRwH-6_AubBwM</code> for <em>Provincia di Ferrara</em>).</p>
  
  <p>As you can see below, <code>Provincia di Ferrara</code> is returned as a string, but not as the place_id I need.</p>
  
  <pre><code>Array (
      [html_attributions] =&gt; Array(
      )
  
      [result] =&gt; Array (
          [address_components] =&gt; Array (
              [0] =&gt; Array (
                  [long_name] =&gt; Comacchio
                  [short_name] =&gt; Comacchio
                  [types] =&gt; Array (
                      [0] =&gt; locality
                      [1] =&gt; political
                  )
              )
  
              [1] =&gt; Array (
                  [long_name] =&gt; Comacchio
                  [short_name] =&gt; Comacchio
                  [types] =&gt; Array (
                      [0] =&gt; administrative_area_level_3
                      [1] =&gt; political
                  )
              )
  
              [2] =&gt; Array (
                  [long_name] =&gt; Provincia di Ferrara
                  [short_name] =&gt; FE
                  [types] =&gt; Array (
                      [0] =&gt; administrative_area_level_2
                      [1] =&gt; political
                  )
              )
  
              [3] =&gt; Array (
                  [long_name] =&gt; Emilia-Romagna
                  [short_name] =&gt; Emilia-Romagna
                  [types] =&gt; Array (
                      [0] =&gt; administrative_area_level_1
                      [1] =&gt; political
                  )
              )
  
              [4] =&gt; Array (
                  [long_name] =&gt; Italy
                  [short_name] =&gt; IT
                  [types] =&gt; Array (
                      [0] =&gt; country
                      [1] =&gt; political
                  )
              )
  
              [5] =&gt; Array (
                  [long_name] =&gt; 44022
                  [short_name] =&gt; 44022
                  [types] =&gt; Array (
                      [0] =&gt; postal_code
                  )
              )
          )
  
          [adr_address] =&gt; &lt;span class="postal-code"&gt;I-44022&lt;/span&gt; &lt;span class="locality"&gt;Comacchio&lt;/span&gt; &lt;span class="region"&gt;FE&lt;/span&gt;, &lt;span class="country-name"&gt;Italy&lt;/span&gt;
          [formatted_address] =&gt; 44022 Comacchio FE, Italy
          [geometry] =&gt; Array (
              [location] =&gt; Array (
                  [lat] =&gt; 44.6940053
                  [lng] =&gt; 12.1793532
              )
  
              [viewport] =&gt; Array (
                  [northeast] =&gt; Array (
                      [lat] =&gt; 44.7056942
                      [lng] =&gt; 12.2000628
                  )
  
                  [southwest] =&gt; Array (
                      [lat] =&gt; 44.6839703
                      [lng] =&gt; 12.15889
                  )
              )
          )
  
          [icon] =&gt; http://maps.gstatic.com/mapfiles/place_api/icons/geocode-71.png
          [id] =&gt; cb8042e2b729756e683d2aff008871f9876081dd
          [name] =&gt; Comacchio
          [place_id] =&gt; ChIJ0yHebbB1fkcR7YujotES0dA
          [reference] =&gt; CoQBdgAAAGSwypFqE8NNsCqFFroul7U-c8ACswn9Zd_O89SAK6nxPTpsevzOLaa9rQa0-ms2SXDgnrAxKkQ7av8KHxjRHL0UB_GD_xBzMM2u5iYCDVhoLtwSKMifSJAX7T0q9pdqeB6kzPa3IbLGpdDcaMOOAWZ8gf1gtbNjr9Wf3oo5cV4JEhAWQYrsRynoan3_W0DMElMSGhQb2BUPnW0s_cCUgeHkskTZwSPNeg
          [scope] =&gt; GOOGLE
          [types] =&gt; Array (
              [0] =&gt; locality
              [1] =&gt; political
          )
  
          [url] =&gt; https://maps.google.com/maps/place?q=44022+Comacchio+FE,+Italy&amp;ftid=0x477e75b06dde21d3:0xd0d112d1a2a38bed
          [vicinity] =&gt; Comacchio
      )
  
      [status] =&gt; OK
  )
  </code></pre>