fork(1) download
  1. <?php
  2.  
  3.  
  4. $bills = array(500, 100);
  5. $totalBills = array(5, 2);
  6. $rndCombination = array(2, 1);
  7.  
  8. function nextCombination($total, $combination){
  9. if($combination[0] == $total[0] && $combination[1] == $total[1] ){
  10. echo "Последняя комбинация:";
  11. print_r($combination);
  12. exit();
  13. }
  14. if($combination[0] > $total[0] || $combination[1] > $total[1]){
  15. echo "Введенная комбинация некорректна.";
  16. exit();
  17. }
  18. if($combination[1] < $total[1]){
  19. $combination[1]++;
  20. }
  21. else{
  22. $combination[1] = 0;
  23. $combination[0]++;
  24. }
  25. print_r($combination);
  26. }
  27.  
  28. echo nextCombination($totalBills, $rndCombination);
Success #stdin #stdout 0.02s 25676KB
stdin
Standard input is empty
stdout
Array
(
    [0] => 2
    [1] => 2
)