note 97463 deleted from function.array-reduce by dave

From: Date: Tue, 11 May 2010 09:25:42 +0000
Subject: note 97463 deleted from function.array-reduce by dave
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-169137@lists.php.net to get a copy of this message
Note Submitter: aercolino at yahoo dot com ---- Thanks to php at keith tyler dot com, knowing that "if you do not provide $initial, the first value used in the iteration is NULL", we can write callbacks that test for is_null() and take any necessary step. Example: <?php function andFunc($a, $b) { return (is_null($a) ? true : $a) && $b; } $foo = array(true, true, true); var_dump(array_reduce($foo, "andFunc")); ?> It returns bool(true), as expected.

« previous php.notes (#169137) next »