-2

Some help please with this thing that was confused me about the correct use of array_splice(); When i copy literally the following code from the php.net website, that appears as follow:

$input = array("red", "green", "blue", "yellow");
array_splice($input, 2);
// $input is now array("red", "green")

But on my localhost, the result is not as shown in the website example. I got this:

Array ( [0] => blue [1] => yellow )

What happens here?

Resource http://php.net/manual/en/function.array-splice.php

1 Answers1

0

This is correct. The return array will contain removed elements, i.e. ( "red", "green" ). The original array will be modified to contain the elements which were not removed, i.e. ( "blue", "yellow" ).

Zbynek Vyskovsky - kvr000
  • 18,186
  • 3
  • 35
  • 43