Level 39
Jan 4, 2021
3
Level 15
Refactor array loop in PHP
Hi,
I have this code:
protected function loopArray($array)
{
$array = [1, 2, 3, 4, 5];
foreach($array as $item) {
$item++;
}
return $array;
}
How can I simplify this?
Please or to participate in this conversation.