Page 1 of 1

Would somebody explain how array_filter filters this array.

Posted: Fri Oct 20, 2006 7:26 am
by impulse()
This is a copy and paste from the

Code: Select all

array_filter
function on uk.php.net.
I'm not understanding why it's filtering elements 1, 3 & 4

Code: Select all

$entry = array(
             0 => 'foo',
             1 => false,
             2 => -1,
             3 => null,
             4 => ''
         );

print_r(array_filter($entry));
Could somebody point this out please?

Stephen,

Posted: Fri Oct 20, 2006 7:37 am
by impulse()
Throw stones at me.

I've just realised why.

Posted: Fri Oct 20, 2006 11:42 am
by s.dot
*throws stones*
php.net wrote:If the callback function is not supplied, array_filter() will remove all the entries of input that are equal to FALSE. See converting to boolean for more information.

Posted: Fri Oct 20, 2006 6:40 pm
by RobertGonzalez
You gotta love the manual...