array_slice
returns a slice of an array
$sliced_array = array_slice($array, 0, 5)
is the code you want in your case to return the first five elements
More Related Contents:
- how can i passed array into a function in php [closed]
- Needle in a Haystack for Php [closed]
- Can I bind an array to an IN() condition in a PDO query?
- Multiple inputs with same name through POST in php
- Creating one array from another array in php [closed]
- Filter array by its keys using an array of allowed keys
- How to echo or print an array in PHP?
- Reference – What does this error mean in PHP?
- Sorting a php array of arrays by custom order
- Difference between method calls $model->relation(); and $model->relation;
- array_unique for objects?
- How do I sort a multidimensional array by one of the fields of the inner array in PHP? [duplicate]
- String with array structure to Array [duplicate]
- Removing array item by value [duplicate]
- Checking if array is multidimensional or not?
- array_key_exists is not working
- How can I use in_array if the needle is an array?
- PHP try-catch blocks: are they able to catch invalid arg types?
- How to get the last element of an array without deleting it?
- Checking if ANY of an array’s elements are in another array
- While destructuring an array, can the same element value be accessed more than once?
- Remove unwanted elements from subarrays in multidimensional array
- How to convert array to a string using methods other than JSON?
- Sort array by value alphabetically php
- Why do I get “Resource id #4” when I apply print_r() to an array in PHP? [duplicate]
- How to set an option from multiple options or array with different values to views as selected in select box using PHP
- CMS Routing in MVC
- Best way to initialize (empty) array in PHP
- Recursive array_search
- Conditionally add associative element to array