note 87581 added to function.array-filter

From: Date: Thu, 11 Dec 2008 14:39:13 +0000
Subject: note 87581 added to function.array-filter
Groups: php.notes 
Request: Send a blank email to php-notes+get-148028@lists.php.net to get a copy of this message
This function filters an array and remove all null values recursively. function array_filter_recursive($input) { foreach ($input as &$value) { if (is_array($value)) { $value = array_filter_recursive($value); } } return array_filter($input); } Or with callback parameter (not tested) : function array_filter_recursive($input, $callback = null) { foreach ($input as &$value) { if (is_array($value)) { $value = array_filter_recursive($value, $callback); } } return array_filter($input, $callback); } ---- Server IP: 213.246.51.26 Probable Submitter: 91.199.11.249 ---- Manual Page -- http://www.php.net/manual/en/function.array-filter.php Edit -- https://master.php.net/note/edit/87581 Del: integrated -- https://master.php.net/note/delete/87581/integrated Del: useless -- https://master.php.net/note/delete/87581/useless Del: bad code -- https://master.php.net/note/delete/87581/bad+code Del: spam -- https://master.php.net/note/delete/87581/spam Del: non-english -- https://master.php.net/note/delete/87581/non-english Del: in docs -- https://master.php.net/note/delete/87581/in+docs Del: other reasons-- https://master.php.net/note/delete/87581 Reject -- https://master.php.net/note/reject/87581 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#148028) next »