I want to return first 5 items from array. How can I do this?
array_slice returns a slice of an array
array_slice
$sliced_array = array_slice($array, 0, 5)
is the code you want in your case to return the first five elements
2.1m questions
2.1m answers
60 comments
56.9k users