fork download
  1. <?php
  2.  
  3. $total = 30;
  4. $skip = 5;
  5.  
  6. $totalAr = array_fill(1, $total, 0);
  7. $a = 1;
  8. foreach ($totalAr as &$value){
  9. $value += $a;
  10. $a++;
  11. }
  12.  
  13. $e = 0;
  14. while(count($totalAr) >= $skip) {
  15. foreach ($totalAr as $k => $v) {
  16. $e++;
  17. if ($e == $skip) {
  18. unset($totalAr[$k]);
  19. $e = 0;
  20. }
  21. }
  22. }
  23.  
  24. print "Чай пьют " . implode(', ', $totalAr);
Success #stdin #stdout 0.02s 52472KB
stdin
Standard input is empty
stdout
Чай пьют 3, 4, 14, 27