<?php
$ids = [100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110];
$users = [1,2,3,4,5];
// Temporary copy of users
$user_ids = [];
foreach( $ids as $id ){
// If our copy is empty, reload it
if(!$user_ids){
$user_ids = $users;
}
// Use array_shift() to grab and remove from the front
echo sprintf('%1$d - %2$d', $id, array_shift($user_ids)), PHP_EOL;
}
echo PHP_EOL;
foreach( $ids as $idx => $id ){
echo sprintf('%1$d - %2$d', $id, ($idx % 5) + 1 ), PHP_EOL;
}
preferences:
24.09 ms | 405 KiB | 5 Q