You want to only get the first 5 items from an array, but if there only exists less than 5 items in the array, you still want to get them all.

The result would be an array variable containing at most 5 items.
Is there a single PHP function that can do this?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.