title: Remove white space from the json data
body: <p>I have script that fetch the data from the database. These data is in multidimensional array. You can say array of array and the out put is encoded in json format. 
  My question is how to remove white space from the beginning and the end of each json value.</p>
  
  <p>Output is:-</p>
  
  <pre><code> {"post":{"id":"4","image":" LIVE_3.JPG ","video":"LIVE_3.MOV","category":""}},
   {"post":{"id":"3","image":" LIVE_2.JPG ","video":"LIVE_2.MOV","category":""}},
   {"post":{"id":"2","image":"LIVE_1.JPG","video":"LIVE_1.MOV","category":""}}  
  </code></pre>
  
  <p>Needed and expected:-</p>
  
  <pre><code>{"post":{"id":"4","image":"LIVE_3.JPG ","video":"LIVE_3.MOV","category":""}},
  {"post":{"id":"3","image":"LIVE_2.JPG ","video":"LIVE_2.MOV","category":""}},
  {"post":{"id":"2","image":"LIVE_1.JPG","video":"LIVE_1.MOV","category":""}}
  </code></pre>
  
  <p>My code is:-</p>
  
  <pre><code>$query = "SELECT * FROM data  ORDER BY ID DESC ";
  $result = mysql_query($query,$link) or die('Errant query:  '.$query);
  
  /* create one master array of the records */
  $posts = array();
  if(mysql_num_rows($result)) {
      while($post = mysql_fetch_assoc($result)) {
          $posts[] = array('post'=&gt;$post);
  
  
      }
  }
  
  /* output in necessary format */
  
      header('Content-type: application/json');
      echo json_encode(array('posts'=&gt;$posts));
  
  
  
  
  /* disconnect from the db */
  @mysql_close($link);
  </code></pre>