title: Replace value of the array when null
body: <p>I created a WebService in php for get data from mySQL DB and returns a JSON.</p>
  
  <p>So, I need that, whenever have <code>null value</code> from my DB, this value is changed for white (<code>= " "</code>).</p>
  
  <p>I did this way, but without success (look the last <code>foreach</code>):</p>
  
  <pre><code>&lt;?php
  
  header("Content-Type: application/json; charset=utf-8;");
  
  include('connectdb.php');
  
  $something = $_GET['cod'];
  $sqlcode = mysql_query("Select descricao, cliente, local from terminal_cartao Where     descricao='$something'");
  $sqlcode2 = mysql_query("Select descricao, cliente, local from terminal_cartao");
  
  $jsonObj= array();
  
  if($something == 'all')
  {
  
  while($result=mysql_fetch_object($sqlcode2))
  {
  $jsonObj[] = $result;
  }
  
  }
  
  else{
  while($result=mysql_fetch_object($sqlcode))
  {
  $jsonObj[] = $result;
  }
  }
  
  foreach ($jsonObj as $key =&gt; $value) {
  if ($value === null) {
      $jsonObj[$key] = ""; 
  }
  }
  
  $final_res =json_encode($jsonObj);
  echo $final_res;
  exit;
  </code></pre>