<<< Previous question <<< Question ID#0391.md >>> Next question >>>
The PHP function array_reduce() is used to turn an array into a single value using a custom callback. What is the output of the following script?
function reducer($total, $elt) {
return $elt + $total;
}
$arr = [1, 2, 3, 4, 5];
echo array_reduce($arr, 'reducer', 1);
- A) 16
- B) 14
- C) 0
- D) 15
Answer
Answer: A