Situation: Got 160 ids in array, need to build xml requests, in sets of max 50 and submit each set separately.
Problem: How to loop the function and continue with ID 51?function doBatch($ids)
Simplified Code:
function doBatch($ids)
{
$start = "<feed>";
foreach($ids as $id)
{
$add .= '<entry>'$id.'</entry>';
}
$stop = "</feed>";
$data = $start.$add.$stop;
post($data);
}
You can split your big array in chunks, with array_chunk.
Edit:
And here’s another little known array function (and I think this one may be needed in your case): array_splice.
Know your array functions young grasshopper! All
10077 of them.