title: JSON - How to merge nested object inside array in php
body: <p>Hi I want to put json nested object with this format:</p>
  
  <pre><code>[{"lat":-6.92015,"lon":107.67024,"value":0.1},{"lat":-6.88283,"lon":107.60149,"value":0.1},..]
  </code></pre>
  
  <p>into this json array :</p>
  
  <pre><code>{"max": 30, "data": [...]}
  </code></pre>
  
  <p>and will result in this format :</p>
  
  <pre><code>{"max": 30, "data": [{"lat":-6.92015,"lon":107.67024,"value":0.1},...]}
  </code></pre>
  
  <p>my current code :</p>
  
  <pre><code>$data[] = array(lat=&gt;(float)$row["geo_lat"], lon=&gt;(float)$row["geo_long"], value=&gt;1);
  $post_data = json_encode(array('max' =&gt; 30, 'data' =&gt; $data));
  echo $post_data;
  </code></pre>
  
  <p>How I can do that? Thanks</p>