title: How to delete object from array inside foreach loop?
body: <p>I iterate through an array of objects and want to delete one of the objects based on it's 'id' property, but my code doesn't work.</p>
  
  <pre><code>foreach($array as $element) {
      foreach($element as $key =&gt; $value) {
          if($key == 'id' &amp;&amp; $value == 'searched_value'){
              //delete this particular object from the $array
              unset($element);//this doesn't work
              unset($array,$element);//neither does this
          } 
      }
  }
  </code></pre>
  
  <p>Any suggestions. Thanks.</p>