title: passing array of objects from javascript to php
body: <p>So I built an array of objects for passing to PHP, but I am wondering wether this is the cleanest way to pass them and will be the easiest to deal with in PHP. </p>
  
  <p>I am partly thrown off by the fact that the number of group components are variable based on what my google maps reverse-geocoder returns.</p>
  
  <p>Each group will be inserted as a separate row into MySql with the parameters of 'name' and 'type'</p>
  
  <pre><code>var neighborhood = extractLongFromAddress(results[0].address_components, "sublocality");
  var town = extractLongFromAddress(results[0].address_components, "locality");
  var stateShort = extractShortFromAddress(results[0].address_components, "administrative_area_level_1");
  var stateLong = extractLongFromAddress(results[0].address_components, "administrative_area_level_1");
  var country = extractLongFromAddress(results[0].address_components, "country");
  
  var groups=[];
  if(town &amp;&amp; stateShort){
    groups.push({name: town+", "+stateShort,
             type:"city"
    });
  }
  
  if(neighborhood &amp;&amp; stateLong){
    groups.push({name: neighborhood+", "+stateShort,
             type:"neighborhood"
    });
  }
  
  if(stateLong){
    groups.push({name:stateLong,
             type:"state"
    });
  }
  
  if(country){
    groups.push({name:country,
             type:"country"
    });
  }
   console.log(groups);
  </code></pre>
  
  <p>sincere thanks for any help. It is greatly appreciated. </p>