title: How to remove an object from JSON array in PHP
body: <p>I have a JSON array. I want to delete the entry that have number <code>4</code> and return the left over array</p>
  
  <pre><code>$filters = '{"1":1,"2":2,"3":4}';
  $fobj = json_decode($filters, TRUE);
  
  foreach($fobj as $key =&gt; $value) 
  { 
  if (in_array(4, $fobj)) {
   unset($fobj[4]);
    }
  }
  echo $filters = json_encode($fobj );
  </code></pre>
  
  <p>But this <code>echo</code> does not give me what I want. I want it to return something like this:</p>
  
  <pre><code>  {"1":1,"2":2}
  </code></pre>