I've got an API I'm working with that accepts a call every 5 seconds, any more than that it wont respond. In each call it will accept 5 records in a batch. I've got a list of 1000s of records that I need to check using the api, so what I'm trying to do is send it my list of records in broken up into batches of 5 every 5 seconds.
I can get most of it to work, but the bit I can't figure is breaking down the list of records which is an array in batches, any idea how to do this?
This is the code I was using below, but it's outputting each individual part of the array every 5 seconds, rather than in batches of 5.
$my_array = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20];
foreach ($my_array as $key => $value) {
sleep (5);
echo $value;
}