Sobes.tech
Junior — Senior

Modifying an array while iterating over it

livecode

Task condition

It is necessary to find out what output the program will produce and how the array will change after executing a loop in which elements are removed from it.

$array = [1,2,3,4,5];
foreach ($array as $k => $v) {
 echo $v;
 unset($array[$k+1]);
}