PHP program to create a new array with n elements removed from the left.

bookmark

<?php
function drop_from_left($items, $n = 1)
{
    return array_slice($items, $n);
}
print_r(drop_from_left([1, 2, 3])); 
print_r(drop_from_left([1, 2, 3, 4], 2));

?>


Output:

Array
(
    [0] => 2
    [1] => 3
)
Array
(
    [0] => 3
    [1] => 4
)