title: Convert PHP Array to JSON Array of object
body: <p>I'm using <a href="https://developers.google.com/chart/interactive/docs/gallery/orgchart" rel="nofollow noreferrer">Google Orgchart</a> in my project. In that I'm returning <code>JSON OBJECT</code> from PHP file.</p>
  
  <p><strong>Problem</strong></p>
  
  <p>My Problem is when I hardcode the value, It works fine. When I return data from PHP file. It did not work. I guess the data format which is returning from PHP file is not correct. File below.</p>
  
  <pre><code>$result = mysql_query("SELECT * FROM emp"); 
      while($row = mysql_fetch_array( $result )) {
          $arr1 = array(
              'v' =&gt; $row['name'],
              'f' =&gt; $row['name']+'&lt;div style="color:red; font-style:italic"&gt;President&lt;/div&gt;',
              '' =&gt; $row['rep'],
              '' =&gt; $row['des'],
          );
          array_push($dataarray, $arr1);
      }
  
  echo json_encode($dataarray);
  </code></pre>
  
  <p>which returns object like below</p>
  
  <p><a href="https://i.stack.imgur.com/pQVt0.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/pQVt0.jpg" alt="enter image description here"></a></p>
  
  <p><strong>How it Should be</strong></p>
  
  <p>My hardcorded <code>JSON OBJECT</code> below </p>
  
  <pre><code>   [
        [{v:'Prabhkar', f:'Prabhkar&lt;div style="color:red; font-style:italic"&gt;President&lt;/div&gt;'},
         '', 'The President'],
        [{v:'Raguram', f:'Raguram&lt;div style="color:red; font-style:italic"&gt;GM&lt;/div&gt;'},
         'Prabhkar', 'GM']
      ]
  </code></pre>
  
  <p>Console Screenshot below:</p>
  
  <p><a href="https://i.stack.imgur.com/pgbHp.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/pgbHp.jpg" alt="enter image description here"></a></p>
  
  <p>Do I need to create a one more array in PHP file. How I suppose to change the PHP array according to above screenshot. sorry for my english. Thank you.</p>