note 94189 deleted from function.array-sum by danbrown

From: Date: Wed, 21 Oct 2009 17:05:27 +0000
Subject: note 94189 deleted from function.array-sum by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-161952@lists.php.net to get a copy of this message
Note Submitter: jriddy at obfuscation dot isnt dot spam-safe dot com ---- Here's another algorithm for array_sub[tract]. I think this general pattern is useful for doing other things with arrays now that we have lambdas (anonymous functions) in PHP: <?php function array_sub( $array ) { return array_reduce($array, function ( $a, $b ) { return $a !== null ? $a - $b : $b; }, null); } ?>

« previous php.notes (#161952) next »