In addition to stefgosselin's answer that has some mistakes: Lets start with his array:

$input = array(1,2,3);

This contains:

array(3) {
    [0]=> int(1)
    [1]=> int(2)
    [2]=> int(3)
}

Then you do array_slice:

var_dump(array_slice($input, 1));

The function will return the values after the first element (thats what the second argument, the offset means). But notice the keys!

array(2) {
    [0]=> int(2)
    [1]=> int(3)
}

Keep in mind that keys aren't preserved, until you pass true for the fourth preserve_keys parameter. Also because there is another length parameter before this, you have to pass NULL if you want to return everything after the offset, but with the keys preserved.

var_dump(array_slice($input, 1, NULL, true));

That will return what stefgosselin (incorrectly) wrote initially.

array(2) {
    [1]=> int(2)
    [2]=> int(3)
}
Answer from totymedli on Stack Overflow
🌐
PHP
php.net › manual › en › function.array-slice.php
PHP: array_slice - Manual
Array slice function that works with associative arrays (keys): function array_slice_assoc($array,$keys) { return array_intersect_key($array,array_flip($keys)); } ... <?php // CHOP $num ELEMENTS OFF THE FRONT OF AN ARRAY // RETURN THE CHOP, SHORTENING THE SUBJECT ARRAY function array_chop(&$arr, $num) { $ret = array_slice($arr, 0, $num); $arr = array_slice($arr, $num); return $ret; }
🌐
W3Schools
w3schools.com › php › func_array_slice.asp
PHP array_slice() Function
The array_slice() function returns selected parts of an array. Note: If the array have string keys, the returned array will always preserve the keys (See example 4). ... <?php $a=array("red","green","blue","yellow","brown"); print_r(array_s...
🌐
GeeksforGeeks
geeksforgeeks.org › php › php-array_slice-function
PHP array_slice() Function - GeeksforGeeks
June 20, 2023 - The array_slice() is an inbuilt function of PHP and is used to fetch a part of an array by slicing through it, according to the users choice.
🌐
O'Reilly
oreilly.com › library › view › php-functions-essential › 073570970X › 073570970X_ch03lev1sec17.html
array_slice - PHP Functions Essential Reference [Book]
September 17, 2001 - array_slice() copies a subsection from an array and returns the subsection as a new array.
Authors   Zak GreantGraeme Merrall
Published   2001
Pages   768
🌐
Jobtensor
jobtensor.com › Tutorial › PHP › en › Array-Functions-array_slice
PHP Built-in array_slice(), Definition, Syntax, Parameters, Examples | jobtensor
The array_slice() function returns selected parts of an array. If the array have string keys, the returned array will always preserve the keys. ... <?php // Example 1 $ages = array("Mark" => 22, "Jeff" => 32, "Mike" => 28); print_r(array_slice($ages, 1)); echo "<br>"; // Example 2 $cities = ...
Find elsewhere
🌐
W3Schools
www-db.deis.unibo.it › courses › TW › DOCS › w3schools › php › func_array_slice.asp.html
PHP array_slice() Function
The array_slice() function returns selected parts of an array. Note: If the array have string keys, the returned array will always preserve the keys (See example 4). ... <?php $a=array("red","green","blue","yellow","brown"); print_r(array_slice($a,1,2)); ?> Run example »
🌐
Locutus
locutus.io › php › array › array_slice
PHP's array_slice in JavaScript | Locutus
1 month ago - You you can install via yarn add locutus and require this function via const array_slice = require('locutus/php/array/array_slice').
🌐
Educative
educative.io › answers › how-to-slice-an-array-in-php
How to slice an array in PHP
To slice an array in PHP, use the array_slice() in-built PHP array function.
🌐
Nusphere
nusphere.com › kb › phpmanual › function.array-slice.htm
PHP Manual: array_slice
PhpED - PHP IDE integrated development environment for developing web sites using PHP, HTML, Perl, JScript and CSS that combines a comfortable editor, debugger, profiler with the MySQl, PostrgeSQL database support based on easy wizards and tutorials.Easy to use for debugging PHP scripts, publishing ...
🌐
GeeksforGeeks
geeksforgeeks.org › php › how-to-slice-an-array-in-php
How to Slice an Array in PHP? - GeeksforGeeks
July 23, 2025 - The array_slice() function is the standard way to slice an array in PHP.
🌐
w3resource
w3resource.com › php › function-reference › array_slice.php
PHP: array_slice() function - w3resource
August 19, 2022 - The array_slice() function is used to extract a slice of an array. Version: (PHP 4 and above) Syntax: array_slice(array_name, starting_position, slice_length, preserve_keys) The array_slice() function returns the sequence of elements from the ...
🌐
YouTube
youtube.com › maths academy
PHP for Beginners: How to use array_slice in PHP - YouTube
Visit the website at: https://www.mathsacademy.com.au for resources and online courses. Support the channel via Patreon: https://www.patreon.com/mathsacademy...
Published   April 21, 2015
Views   2K