title: PHP formatting for GeoJSON
body: <p>Trying to use PHP to format data for the geometry part of GeoJSON (Polygon)</p>
  
  <pre><code>$sql = "SELECT ST_AsGeoJSON(`geom`) as Geo FROM `usa` WHERE 1";
  </code></pre>
  
  <p>Returns records that look like:  </p>
  
  <pre><code>{"type": "Polygon", "coordinates": [[[-101.4073933...
  </code></pre>
  
  <p>My code so far, I tried formatting the geometry block 3 different ways, all failed.:</p>
  
  <pre><code>while ($res = mysqli_fetch_array($result,MYSQLI_ASSOC)) {
  
  $msg [] = array(
          'type' =&gt; 'Feature',
  
          'geometry' =&gt; 
              $res['Geo'],
           /// ERROR  "geometry" member should be object, but is an String instead
          //"geometry":"{\"type\": \"Polygon\", \"coordinates\": [[[-104.05361517875079, 41.698
  
  
          'geometry' =&gt; array(
              $res['Geo'],
          ),   ///ERROR "geometry" member should be object, but is an Array instead
          //"geometry":["{\"type\": \"Polygon\", \"coordinates\": [[[-104.05361517875079, 41.6
  
  
          'geometry' =&gt; array(
              'type' =&gt; $res['Geo'].['type'],
              'coordinates' =&gt; $res['Geo'].['coordinates'],
          ),  
          //"geometry":{"type":"{\"type\": \"Polygon\", \"coordinates\": [[[[-122.4020155875262, 48.22521
  </code></pre>
  
  <p>It should end up looking something like this:</p>
  
  <pre><code>"geometry": { "type": "Polygon", "coordinates": [[[  -73.3450469
  </code></pre>