Answer the question
In order to leave comments, you need to log in
Can't figure out how to write a php function?
This is what it looks like so far
)->reduce(function ($carry, $item) {
$startCount = 0;
foreach ($item as $value) {
// вычисления
}
$startCount = $result; // в $result вычисления после foreach лежат
$carry[] = $result;
return $carry;
}, []);
Answer the question
In order to leave comments, you need to log in
You are doing something strange.
The result of the previous iteration is contained in $carry.
The result of the current iteration must be returned with return
Why do you need $startCount?
If you really need an "external" variable, you can fasten it like this https://ideone.com/n0nBVZ
If you are converting one array to another, then perhaps not reduce, but array_map is more suitable for you.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question