Array Head

Get the first n elements of an array.

Code

General
array_slice($arr, 0, $n);

Parameters

Array to slice

Number of elements

Server

More PHP Snippets