|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2012-01-27 18:04 UTC] benjamwelker at gmail dot com
Description: ------------ A function like array array_filter_recursive ( array $array [, callback $callback] ) would be very useful. I'm not sure how it would react when encountering empty arrays within the given array, though. The expected result would probably be to keep the empty arrays. Although removing them would be desired under certain conditions as well. PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Nov 02 04:00:02 2025 UTC |
In my opinion, adding more array_*_recursive() functions should be avoided. Instead it might be useful to have array_flatten(), so one could do array_filter(array_flatten($array), $callback) Then again, defining array_flatten() in userland is quite simple: function array_flatten($array) { return array_reduce($array, 'array_merge', []); } Anyhow, with regard to the mentioned issue of empty arrays, it seems indeed best to leave the implementation for userland.