note 108619 deleted from function.array-reduce by salathe
| From: | salathe@php.net | Date: | Fri, 11 May 2012 08:44:58 +0000 |
| Subject: | note 108619 deleted from function.array-reduce by salathe | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-187934@lists.php.net to get a copy of this message | ||
Note Submitter: norm2782
----
<?php
$n = array_reduce(array(10, 5, 1), function($x, $xs) { return $x - $xs; }, 20);
// If right-associative, we should get the equivalent of 20 - (10 - (5 - 1)) = 14
// If left-associative, we should get the equivalent of ((20 - 10) - 5) - 1 = 4
echo $n; // echoes 4, so array_reduce is left-associative