fork(1) download
  1. <?php
  2. $total = 15;
  3. $skip = 5;
  4. $array = array();
  5. $char = 0;
  6.  
  7. $array = range(1, $total);
  8. while (count($array) >= $skip) {
  9. foreach ($array as $key => $value) {
  10. $char += 1;
  11. if ($char == $skip) {
  12. unset($array[$key]);
  13. $char = 0;
  14. }
  15. }
  16. }
  17. var_dump($array);
Success #stdin #stdout 0.02s 24400KB
stdin
Standard input is empty
stdout
array(4) {
  [0]=>
  int(1)
  [1]=>
  int(2)
  [6]=>
  int(7)
  [12]=>
  int(13)
}