fork(1) download
  1. <?php
  2.  
  3.  
  4. $total = 30;
  5. $skip = 5;
  6.  
  7. $order = range(1, $total);
  8.  
  9. while (count($order)>=$skip) {
  10. for ($i=1; $i<=$total; $i++) {
  11. if ($i % $skip == 0) {
  12. unset($order[$i-1]);
  13. }
  14. }
  15. $order = array_merge($order);
  16. }
  17. print_r($order);
Success #stdin #stdout 0.02s 24448KB
stdin
Standard input is empty
stdout
Array
(
    [0] => 1
    [1] => 2
    [2] => 3
    [3] => 4
)