note 111764 added to function.array-filter

From: Date: Tue, 26 Mar 2013 11:10:58 +0000
Subject: note 111764 added to function.array-filter
Groups: php.notes 
Request: Send a blank email to php-notes+get-194209@lists.php.net to get a copy of this message
<?php function array_filter_recursive ($data) { $original = $data; $data = array_filter($data); $data = array_map(function ($e) { return is_array($e) ? array_filter_recursive($e) : $e; }, $data); return $original === $data ? $data : array_filter_recursive($data); } $data = ['a' => 0, 'b' => [], 'c' => [[]], 'd' => [[[[]]]], 'e' => 'foo', 'f' => [[['a']]], [true], [[],['a'], [true, false]]]; $data = array_filter_recursive($data); ?> ---- Server IP: 69.147.83.199 Probable Submitter: 91.85.156.201 ---- Manual Page -- http://php.net/manual/en/function.array-filter.php Edit -- https://master.php.net/note/edit/111764 Del: integrated -- https://master.php.net/note/delete/111764/integrated Del: useless -- https://master.php.net/note/delete/111764/useless Del: bad code -- https://master.php.net/note/delete/111764/bad+code Del: spam -- https://master.php.net/note/delete/111764/spam Del: non-english -- https://master.php.net/note/delete/111764/non-english Del: in docs -- https://master.php.net/note/delete/111764/in+docs Del: other reasons-- https://master.php.net/note/delete/111764 Reject -- https://master.php.net/note/reject/111764 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#194209) next »