I have array:
array('a','b','c','d','e');
And I want to trim it to 3 elements, so we end up with:
array('a','b','c');
What's the best practice to achieve this with optimisation in mind? My arrays are massive.
What I've tried so far
foreach()
loop through array and store the first 3 elements.- Count arrays and use
array_pop()
.
I feel there is a standard function or approach to this.