3v4l.org

run code in 500+ PHP versions simultaneously
<?php error_reporting(-1); $amount = 54000; $bills = array( 5000 => 10, 1000 => 0, 500 => 5, 100 => 23 ); $answer = array(); echo "Сумма: {$amount}\n"; if ($amount <= 0){ echo "Выдача невозможна: введенная сумма меньше или равна 0\n"; }else if ($amount % 100 <> 0){ echo "Выдача невозможна: введенная сумма не кратна 100\n"; }else { foreach($bills as $par => $quantity){ $i = floor($amount/$par); if ($i > 0 && $quantity > 0){ if ($i <= $quantity){ $amount = $amount - $par * $i; $answer[] = $i . "X" . $par; }else { $amount = $amount - $par * $quantity; $answer[] = $quantity . "X" . $par; } } } if ($amount == 0){ echo "Выдача возможна, число купюр:\n"; $string = implode(" ", $answer); echo "{$string}\n"; }else { echo "Выдача невозможна, недостаточно купюр.\n"; } }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 12, Position 2 = 14
Branch analysis from position: 12
1 jumps found. (Code = 42) Position 1 = 61
Branch analysis from position: 61
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 14
2 jumps found. (Code = 43) Position 1 = 17, Position 2 = 19
Branch analysis from position: 17
1 jumps found. (Code = 42) Position 1 = 61
Branch analysis from position: 61
Branch analysis from position: 19
2 jumps found. (Code = 77) Position 1 = 20, Position 2 = 50
Branch analysis from position: 20
2 jumps found. (Code = 78) Position 1 = 21, Position 2 = 50
Branch analysis from position: 21
2 jumps found. (Code = 46) Position 1 = 29, Position 2 = 31
Branch analysis from position: 29
2 jumps found. (Code = 43) Position 1 = 32, Position 2 = 49
Branch analysis from position: 32
2 jumps found. (Code = 43) Position 1 = 34, Position 2 = 42
Branch analysis from position: 34
1 jumps found. (Code = 42) Position 1 = 49
Branch analysis from position: 49
1 jumps found. (Code = 42) Position 1 = 20
Branch analysis from position: 20
Branch analysis from position: 42
1 jumps found. (Code = 42) Position 1 = 20
Branch analysis from position: 20
Branch analysis from position: 49
Branch analysis from position: 31
Branch analysis from position: 50
2 jumps found. (Code = 43) Position 1 = 53, Position 2 = 60
Branch analysis from position: 53
1 jumps found. (Code = 42) Position 1 = 61
Branch analysis from position: 61
Branch analysis from position: 60
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 50
filename:       /in/WDC9X
function name:  (null)
number of ops:  62
compiled vars:  !0 = $amount, !1 = $bills, !2 = $answer, !3 = $quantity, !4 = $par, !5 = $i, !6 = $string
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   INIT_FCALL                                                   'error_reporting'
          1        SEND_VAL                                                     -1
          2        DO_ICALL                                                     
    5     3        ASSIGN                                                       !0, 54000
    7     4        ASSIGN                                                       !1, <array>
   13     5        ASSIGN                                                       !2, <array>
   14     6        ROPE_INIT                                         3  ~12     '%D0%A1%D1%83%D0%BC%D0%BC%D0%B0%3A+'
          7        ROPE_ADD                                          1  ~12     ~12, !0
          8        ROPE_END                                          2  ~11     ~12, '%0A'
          9        ECHO                                                         ~11
   15    10        IS_SMALLER_OR_EQUAL                                          !0, 0
         11      > JMPZ                                                         ~14, ->14
   16    12    >   ECHO                                                         '%D0%92%D1%8B%D0%B4%D0%B0%D1%87%D0%B0+%D0%BD%D0%B5%D0%B2%D0%BE%D0%B7%D0%BC%D0%BE%D0%B6%D0%BD%D0%B0%3A+%D0%B2%D0%B2%D0%B5%D0%B4%D0%B5%D0%BD%D0%BD%D0%B0%D1%8F+%D1%81%D1%83%D0%BC%D0%BC%D0%B0+%D0%BC%D0%B5%D0%BD%D1%8C%D1%88%D0%B5+%D0%B8%D0%BB%D0%B8+%D1%80%D0%B0%D0%B2%D0%BD%D0%B0+0%0A'
   15    13      > JMP                                                          ->61
   17    14    >   MOD                                                  ~15     !0, 100
         15        IS_NOT_EQUAL                                                 ~15, 0
         16      > JMPZ                                                         ~16, ->19
   18    17    >   ECHO                                                         '%D0%92%D1%8B%D0%B4%D0%B0%D1%87%D0%B0+%D0%BD%D0%B5%D0%B2%D0%BE%D0%B7%D0%BC%D0%BE%D0%B6%D0%BD%D0%B0%3A+%D0%B2%D0%B2%D0%B5%D0%B4%D0%B5%D0%BD%D0%BD%D0%B0%D1%8F+%D1%81%D1%83%D0%BC%D0%BC%D0%B0+%D0%BD%D0%B5+%D0%BA%D1%80%D0%B0%D1%82%D0%BD%D0%B0+100%0A'
   17    18      > JMP                                                          ->61
   20    19    > > FE_RESET_R                                           $17     !1, ->50
         20    > > FE_FETCH_R                                           ~18     $17, !3, ->50
         21    >   ASSIGN                                                       !4, ~18
   21    22        INIT_FCALL                                                   'floor'
         23        DIV                                                  ~20     !0, !4
         24        SEND_VAL                                                     ~20
         25        DO_ICALL                                             $21     
         26        ASSIGN                                                       !5, $21
   22    27        IS_SMALLER                                           ~23     0, !5
         28      > JMPZ_EX                                              ~23     ~23, ->31
         29    >   IS_SMALLER                                           ~24     0, !3
         30        BOOL                                                 ~23     ~24
         31    > > JMPZ                                                         ~23, ->49
   23    32    >   IS_SMALLER_OR_EQUAL                                          !5, !3
         33      > JMPZ                                                         ~25, ->42
   24    34    >   MUL                                                  ~26     !4, !5
         35        SUB                                                  ~27     !0, ~26
         36        ASSIGN                                                       !0, ~27
   25    37        CONCAT                                               ~30     !5, 'X'
         38        CONCAT                                               ~31     ~30, !4
         39        ASSIGN_DIM                                                   !2
         40        OP_DATA                                                      ~31
   23    41      > JMP                                                          ->49
   27    42    >   MUL                                                  ~32     !4, !3
         43        SUB                                                  ~33     !0, ~32
         44        ASSIGN                                                       !0, ~33
   28    45        CONCAT                                               ~36     !3, 'X'
         46        CONCAT                                               ~37     ~36, !4
         47        ASSIGN_DIM                                                   !2
         48        OP_DATA                                                      ~37
   20    49    > > JMP                                                          ->20
         50    >   FE_FREE                                                      $17
   32    51        IS_EQUAL                                                     !0, 0
         52      > JMPZ                                                         ~38, ->60
   33    53    >   ECHO                                                         '%D0%92%D1%8B%D0%B4%D0%B0%D1%87%D0%B0+%D0%B2%D0%BE%D0%B7%D0%BC%D0%BE%D0%B6%D0%BD%D0%B0%2C+%D1%87%D0%B8%D1%81%D0%BB%D0%BE+%D0%BA%D1%83%D0%BF%D1%8E%D1%80%3A%0A'
   34    54        FRAMELESS_ICALL_2                implode             ~39     '+', !2
         55        ASSIGN                                                       !6, ~39
   35    56        NOP                                                          
         57        FAST_CONCAT                                          ~41     !6, '%0A'
         58        ECHO                                                         ~41
   32    59      > JMP                                                          ->61
   37    60    >   ECHO                                                         '%D0%92%D1%8B%D0%B4%D0%B0%D1%87%D0%B0+%D0%BD%D0%B5%D0%B2%D0%BE%D0%B7%D0%BC%D0%BE%D0%B6%D0%BD%D0%B0%2C+%D0%BD%D0%B5%D0%B4%D0%BE%D1%81%D1%82%D0%B0%D1%82%D0%BE%D1%87%D0%BD%D0%BE+%D0%BA%D1%83%D0%BF%D1%8E%D1%80.%0A'
   39    61    > > RETURN                                                       1

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
178.4 ms | 2580 KiB | 17 Q