Linux Ask!

Linux Ask! is a Q & A web site specific for Linux related questions. Questions are collected, answered and audited by experienced Linux users.

Sep 122011

How to remove object from array inside foreach loop?


In PHP, to remove object (e.g. with the key = foo in the following example) from array inside foreach loop, you can try:


foreach($array as $key=> $value) {
    if ($key == "foo") {

 Leave a Reply



You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>