title: How to Remove Square bracket from JSON, PHP or javascript?
body: <p><strong>Requirement :</strong>
  how can i convert the following json format.</p>
  
  <p><strong>From :</strong></p>
  
  <pre><code>[
  {"u0":{"user_id":"124", "name":"Eloise R. Morton"}},
  {"u1":{"user_id":"126", "name":"Mary S. Williams"}}
  ]
  </code></pre>
  
  <p><strong>To :</strong></p>
  
  <pre><code> {
   "u0":{"user_id":"124", "name":"Eloise R. Morton"},
   "u1":{"user_id":"126", "name":"Mary S. Williams"}
   }
  </code></pre>
  
  <p>I want to delete/remove the first and last square brackets from JSON.</p>
  
  <p><strong>PHP code :</strong></p>
  
  <pre><code>$sql = "SELECT * FROM user_list";
  $result = $conn-&gt;query($sql);
  $user_count=0;
  if ($result-&gt;num_rows &gt; 0) {
      // output data of each row
      while($row = $result-&gt;fetch_assoc()) {
          $user_count_id="u".$user_count;
          $user_count++;
          $user_list[]=   array($user_count_id=&gt;$row);
      }
  } else {
      echo "0 results";
  }
  echo json_encode($user_list);
  $conn-&gt;close();
  </code></pre>
  
  <p><strong>Javascript code :</strong></p>
  
  <pre><code>function update_user_list(){
      //Fetch data
          $.ajax( "user_list.php" ).done(function(json) {
          user_list       =   json;
          var add_user="";
          for(var obj in user_list){
              add_user +=     '...generate HTML.....';
          }
          $('.user-list-panel .user-table').html(add_user);
          })
      .fail(function() {
          alert( "error" );
      });
  </code></pre>