note 90101 deleted from function.array-filter by danbrown

From: Date: Mon, 06 Apr 2009 16:22:41 +0000
Subject: note 90101 deleted from function.array-filter by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-152871@lists.php.net to get a copy of this message
Note Submitter: Gravis ---- this actually doesnt use the callback but it's a filter worth mentioning. removes all empty() elements in an array, even multidimensional ones: <?php function array_remove_empty($array) { $new_array = array(); foreach($array as $key => $value) { if(is_array($value)){$value = array_remove_empty($value);} if(!empty($value)){$new_array[$key] = $value;} } return $new_array; } ?> it's inefficient but it's easy to understand and works nonetheless.

« previous php.notes (#152871) next »