note 94189 added to function.array-sum

From: Date: Wed, 21 Oct 2009 16:57:13 +0000
Subject: note 94189 added to function.array-sum
Groups: php.notes 
Request: Send a blank email to php-notes+get-161951@lists.php.net to get a copy of this message
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); } ?> ---- Server IP: 192.41.40.227 Probable Submitter: 70.182.68.137 ---- Manual Page -- http://www.php.net/manual/en/function.array-sum.php Edit -- https://master.php.net/note/edit/94189 Del: integrated -- https://master.php.net/note/delete/94189/integrated Del: useless -- https://master.php.net/note/delete/94189/useless Del: bad code -- https://master.php.net/note/delete/94189/bad+code Del: spam -- https://master.php.net/note/delete/94189/spam Del: non-english -- https://master.php.net/note/delete/94189/non-english Del: in docs -- https://master.php.net/note/delete/94189/in+docs Del: other reasons-- https://master.php.net/note/delete/94189 Reject -- https://master.php.net/note/reject/94189 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#161951) next »