title: convert stdclass object array to json correct
body: <p>Sorry for my English, I need help I want to convert a query which will return this.</p>
  
  <pre><code>{"ids":"1","user":"aki","last":"terris","job":"programmer"}{"ids":"1","user":"ako","last":"acros","job":"Artist"}
  </code></pre>
  
  <p>Change it to</p>
  
  <pre><code>{
    "users": [
      {
        "user": "aki",
        "last": "terris",
        "job": "programmer"
      },
      {
        "user": "ako",
        "last": "acros",
        "job": "Artist"
      }
    ]
  }
  </code></pre>
  
  <p>I tried with while, foreach but none gives me a valid format, some help</p>
  
  <p>consult:</p>
  
  <pre><code>$sql = $db-&gt;query("SELECT * FROM user_s WHERE ids = '1' ");    
  $set_users = $sql;
  </code></pre>
  
  <p>Ex :</p>
  
  <pre><code>$entity = array();    
  while ($get_users = $set_users-&gt;fetch_object()) {
  
      $entity = array(
          'id' =&gt; $get_users-&gt;id,
          'user' =&gt; $get_users-&gt;user
          );
  
  }
  
  $fsi = array(
      'users' =&gt; $entity, 
      );
  
  echo $fsi;
  </code></pre>