from documentation, in simple terms I have inferred that array_reduce takes an array as first parameter, processes according to the function defined in second argument, and iterates over the result, till all the values of the first parameter array are exhausted.
But particularly in this example, it takes the array returned from getActiveWidgets()
. Till here ok, What is use statement?
$widgets = array_reduce(
ThemeActiveWidgets::getActiveWidgets(),
function ($carry, $item) use($model) {
if ($item['part_id'] === $model['id']) {
$carry[]=$item;
}
return $carry;
},
[]
);