On 11/16/2011 11:12 AM, Jim Williams wrote:
I just ran across a simple problem I couldn't solve, namely to create a function that does the opposite of array_filter, call it array_sanitize. The closest I could come doesn't work for anonymous functions:
Would this do the job? function array_sanitize($array,$filterName) { return array_diff($array,array_filter($array,$filterName)); } Seems to work in my testing: $a = array('a'=>6,'b'=>1,'c'=>4,'d'=>9); $isOdd = create_function('$arg','return $arg % 2 == 1;'); print_r(array_sanitize($a, $isOdd)); Dan _______________________________________________ New York PHP Users Group Community Talk Mailing List http://lists.nyphp.org/mailman/listinfo/talk http://www.nyphp.org/Show-Participation