Answers for "php get index of current item array_reduce"

PHP
1

php get index of current item array_reduce

$i = 0;
$p = array_reduce($array, function($output, $item) use (&$i, $array) {
   // use $i
   // do something with $item and/or $output
   if ($array[$i]) {
     // perform operation on $output
   }
   $i++; // increment $i
   return $output;
}, $initial);
Posted by: Guest on January-09-2022

Code answers related to "php get index of current item array_reduce"

Browse Popular Code Answers by Language