title: PHP Json Help need?
body: <p>I need to convert the below result. I generate this JSON array using PHP but now I need the same result into a single curly brace.  Below is my PHP code to generate the JSON.</p>
  
  <pre><code>    $arr = array();
      #If no data was returned, check for any SQL errors 
      if ($res == false) 
      { 
         echo 'Query not Executed : '.  die(print_r(sqlsrv_errors(), TRUE));
      }
      else
      {       
          while($obj = sqlsrv_fetch_array($res, SQLSRV_FETCH_ASSOC))
          {
              $arr[] = array(
                  'code' =&gt; array_search($obj['name'], $countries_iso), 
                  'total' =&gt; $obj['Total']
                  );
          }
      }
  
      header("Content-type: application/json");    
      #Output the JSON data 
  
      print (json_encode($arr));
  </code></pre>
  
  <h2>Output of above PHP code:</h2>
  
  <pre><code> [
    {
     code: "AF",
     total: 1
    },
    {
     code: "DZ",
     total: 1
    },
    {
     code: "AS",
     total: 2
    }
   ]
  </code></pre>
  
  <h2>But I want to show like below result:</h2>
  
  <pre><code> {
    "AF":1
    "DZ": 1,
    "AS": 2
   }
  </code></pre>