![]() ![]() ![]() You can change this behaviour by setting preserve_keys to true. If it is omitted, then the sequence will have everything from offset up until the end of the array.īool-$preserve_keys-Note that array_slice will reorder and reset the array indices by default. If length is given and is negative then the sequence will stop that many elements from the end of the array. Int|null-$length-If length is given and is positive, then the sequence will have that many elements in it. If offset is negative, the sequence will start that far from the end of the array. Int-$offset-If offset is non-negative, the sequence will start at that offset in the array. PHP function array_slice(array $array, int $offset, ?int $length, bool $preserve_keys = false) string $slice = array_slice($numbers, 1, 3) // Extracts a slice starting from the second element with length 3 You can extract a slice of an array using the array_slice() function.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |