note 129675 added to function.array-reduce

From: Date: Tue, 30 Jul 2024 06:55:59 +0000
Subject: note 129675 added to function.array-reduce
Groups: php.notes 
Request: Send a blank email to php-notes+get-221448@lists.php.net to get a copy of this message
If you need access to the keys of the array in your callback, this alternative uses the same signatures as array_reduce() and its callback, with the addition of a $key argument: <?php function array_reduce_assoc(array $array, callable $callback, mixed $initial = null): mixed { foreach ($array as $key => $item) { $initial = call_user_func($callback, $initial, $item, $key); } return $initial; } ---- Server IP: 45.112.84.4 Probable Submitter: 80.90.5.137 (proxied: 60.231.232.99) ---- Manual Page -- https://php.net/manual/en/function.array-reduce.php Edit -- https://main.php.net/note/edit/129675 Del: integrated -- https://main.php.net/note/delete/129675/integrated Del: useless -- https://main.php.net/note/delete/129675/useless Del: bad code -- https://main.php.net/note/delete/129675/bad+code Del: spam -- https://main.php.net/note/delete/129675/spam Del: non-english -- https://main.php.net/note/delete/129675/non-english Del: in docs -- https://main.php.net/note/delete/129675/in+docs Del: other reasons-- https://main.php.net/note/delete/129675 Reject -- https://main.php.net/note/reject/129675 Search -- https://main.php.net/manage/user-notes.php

« previous php.notes (#221448) next »