If you want to preserve key, you can pass in true as the fourth argument:
array_slice($a, -3, 3, true);
More Related Contents:
- PHP create new array by value
- Get first and second element of array [duplicate]
- count how many duplicate keys are in array of objects?
- How to remove duplicate values from a multi-dimensional array in PHP
- Convert multidimensional array into single array
- PHP Sort Array By SubArray Value
- Using a string path to set nested array data [duplicate]
- create array tree from array list
- How to get random value out of an array?
- Finding the subsets of an array in PHP
- How to sort date array in php?
- php return only duplicated entries from an array
- Flatten multidimensional array concatenating keys [duplicate]
- Merge array items into string
- How to get the last n items in a PHP array as another array?
- How can I sort an array of UTF-8 strings in PHP?
- Sort array of objects by date field
- Generate an associative array from an array of rows using one column as keys and another column as values
- Counting occurrence of specific value in an Array with PHP [duplicate]
- Process CSV Into Array With Column Headings For Key
- Print $_POST variable name along with value
- How can I add a condition inside a php array?
- Pass array literal to PostgreSQL function
- Isolate comma-separated values, remove duplicates and empty values, then sort
- How to get the length of longest string in an array
- Best method for converting a PHP array to javascript
- Use json_decode() to create array insead of an object
- Group 2d array’s row data by one column and sum another column within each group to produce a reduced 2d array
- Rename key in each row of a 2d array
- Conditionally add associative element to array