From: Operating system: PHP version: Irrelevant Package: Arrays related Bug Type: Feature/Change Request Bug description:New argument $invert for array_filter()
Description: ------------ I think, it would be useful to add new argument $invert to array_filter() function. It will be most useful to use built-in functions as a callback. For example this call: $result = array_filter($values, 'is_null', true); should to _remove_ all NULLs from array. May be the parameter should be named $positive and have default value TRUE (and FALSE for inversion) to make code readable. Test script: --------------- $values = array(42, 'foo', false, null, array(), ''); var_dump( array_filter($values, null, true), // no callback - leave false value array_filter($values, 'is_null', true) // leave non-null values ); Expected result: ---------------- array(5) { [0]=> bool(false) [1]=> NULL [2]=> array(0) { } [3]=> string(0) "" } array(5) { [0]=> int(42) [1]=> string(3) "foo" [2]=> bool(false) [3]=> array(0) { } [4]=> string(0) "" } -- Edit bug report at https://bugs.php.net/bug.php?id=55633&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=55633&r=trysnapshot54 Try a snapshot (PHP 5.3): https://bugs.php.net/fix.php?id=55633&r=trysnapshot53 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=55633&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=55633&r=fixed Fixed in SVN and need be documented: https://bugs.php.net/fix.php?id=55633&r=needdocs Fixed in release: https://bugs.php.net/fix.php?id=55633&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=55633&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=55633&r=needscript Try newer version: https://bugs.php.net/fix.php?id=55633&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=55633&r=support Expected behavior: https://bugs.php.net/fix.php?id=55633&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=55633&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=55633&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=55633&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=55633&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=55633&r=dst IIS Stability: https://bugs.php.net/fix.php?id=55633&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=55633&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=55633&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=55633&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=55633&r=mysqlcfg