Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

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);
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #php #index #current #item
ADD COMMENT
Topic
Name
5+1 =