Take a look at this page with the documentation for array_splice
, and inspect the first example.
http://www.php.net/manual/en/function.array-splice.php
It is confusing me as the following code in example 1 is not correct as far as I can tell,
$input = array("red", "green", "blue", "yellow");
array_splice($input, 2);
// $input is now array("red", "green")
When I do this on my local machine I get the following,
$array = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20);
array_splice($array, 10);
// $array is now array(11, 12, 13, 14, 15, 16, 17, 18, 19, 20);
On PHPs page the example returns the elements, whereas on my local machine it removes them instead?
I don't get it? Am I missing something?
Probably the documentation is wrong.
I tested your code and the code on php.net and works perfectly great, as in your example.
I am getting this:
$input = array("red", "green", "blue", "yellow");
array_splice($input, 2);
// $input is now array("blue", "yellow")
So i would say that php.net is wrong (weird!! isn't it????)