Understand you are not using or talking about array keys but rather a number from a direction. Add an extra color to the middle of your example and you will see the result is the same.
$input = array("red", "green", "blue", "Orange", "yellow");
This is because you are saying “I will keep the first one”
array_splice($input, 1);
… and I will keep the last one because you have a minus sign (end) so from the (end) 1 place will be kept. Everything between is removed.
array_splice($input, 1, -1);
If you had -2 (from the end) then the two end values are kept. e.g.
array_splice($input, 1, -2);
Array
(
[0] => red
[1] => Orange
[2] => yellow
)
Say you don’t want the first item but the last three.
array_splice($input, 0, -3);
Array
(
[0] => blue
[1] => Orange
[2] => yellow
)
OR again, just the first three items.
array_splice($input, 3);
Array
(
[0] => red
[1] => green
[2] => blue
)
I more example to really confuse you. Let’s say you want to remove the third item and replace it with two more items but the rest you’ll keep. So “start position” or the number you want to keep is 2 and you want to remove 1 item from the “start position” and “replace” it with two items written as an array.
$input = array("red", "green", "blue", "Orange", "yellow");
$replace = array("lavender","black");
array_splice($input, 2, 1,$replace);
The result.
Array
(
[0] => red
[1] => green
[2] => lavender
[3] => black
[4] => Orange
[5] => yellow
)
…and if you were skipping 2 and removing 2 and replacing those with your $replace
array.
array_splice($input, 2, 2,$replace);
Array
(
[0] => red
[1] => green
[2] => lavender
[3] => black
[4] => yellow
)