1

If I have a single array that has around 5000 elements.

I want 50 arrays out it having 100 elements each. And of course if there are 4923 elements, out of the 50 arrays, there will be 23 in the last one.

I know there must be some built-in function for this. But can't get around one.

1 Answer 1

2

It is https://www.php.net/array_chunk

$splitted = array_chunk($my_array, 100);
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks! Just couldn't recall the function name.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.