php process 50 array elements at a time and remove them when done -


i have array of 100 links (each array element link) , want process 5 @ time. thinking of using array_slice() achieve once first 5 elements processed want remove them array unprocessed links remain in until elements processes , array becomes empty.

my code looks this:

$links = array("http://www.example.com", "http://www.example.com", "http://www.example.com", "http://www.example.com", "http://www.example.com", "http://www.example.com", "http://www.example.com", "http://www.example.com", "http://www.example.com");  $first_five = array_slice($links, 0, 5);  foreach($first_five $ff) { process_link($ff); } 

// far how remove processed elements , process remaining onces until $links[] empty? ?>

array_chunk() might you're looking for. splits given array array of arrays, each containing specified number of elements:

foreach (array_chunk($links, 5) $slice) {     // $slice array containing 5 elements     // process further } 

demo


Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -