I am using array shift to bypass the first element of an array, but it doesn't seem to be working
say I have an array
$myarray = array
(
[0] => monkey
[1] => pig
[2] => frog
[3] => dog
);

when I array shift and print the content of the array I am only getting the first element. I thought that I would be removing the first element
This is what I am getting

$newarray = array_shift($myarray);
print_r($newarray);

displays

array(
[0] => monkey
)

When I want it to display

array(
[0] => pig
[1] => frog
[2] => dog
)

anyone know what's going on?

    Hi,

    array_shift returns the element removed, so

    $shifted = array_shift($myarray); 
    print_r($myarray); 
    

    should work.

    Thomas

      Write a Reply...