3v4l.org

run code in 300+ PHP versions simultaneously
<?php $hotels = [ ['Cala', 3, 8.7, 6000], ['Ocean', 3, 8.2, 6150], ['Orchid', 3, 8.0, 7200], ['Ya', 3, 8.7, 6950], ['Chaba', 3, 8.2, 7120], ]; $totalHotelsNumber = 2; $starCoef = 0.2; $ratingCoef = 2000; for ( $i=0; $i<count($hotels); $i++ ) { $hotels[4] = 0; } for ( $i=0; $i<count($hotels); $i++ ) { for ( $j=$i+1; $j<count($hotels); $j++ ) { echo 'Comparing '.$hotels[$i][0].' and '.$hotels[$j][0].'...'."\r\n"; $starDifference = $hotels[$i][1]-$hotels[$j][1]; $ratingToCompensate = $starDifference*$starCoef; $rating += $ratingToCompensate; $ratingDifference = $rating-$hotels[$j][2]; $priceToCompensate = $ratingDifference*$ratingCoef; $price -= $priceToCompensate; echo $price.' VS '.$hotels[$j][2]."\r\n"; if ( $price > $hotels[$j][2] ) { echo $hotels[$i][0].' wins!'."\r\n"; $hotels[$i][4]++; } else { echo $hotels[$j][0].' wins!'."\r\n"; $hotels[$j][4]++; } echo "\r\n".'----------'."\r\n"; } } usort($hotels, function($hotelA, $hotelB){ return $hotelA[4]-$hotelB[4]; }); echo "\r\n".'----------'."\r\n"; echo 'Top:'."\r\n\r\n"; for ( $i=0; $i<count($hotels); $i++ ) { echo $hotels[$i][0].': '.$hotels[$i][4]."\r\n"; } echo "\r\n".'----------'."\r\n"; echo 'Finalists:'."\r\n\r\n"; for ( $i=0; $i<=1; $i++ ) { echo $hotels[$i][0]."\r\n"; }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 9
Branch analysis from position: 9
2 jumps found. (Code = 44) Position 1 = 12, Position 2 = 6
Branch analysis from position: 12
1 jumps found. (Code = 42) Position 1 = 76
Branch analysis from position: 76
2 jumps found. (Code = 44) Position 1 = 79, Position 2 = 14
Branch analysis from position: 79
1 jumps found. (Code = 42) Position 1 = 97
Branch analysis from position: 97
2 jumps found. (Code = 44) Position 1 = 100, Position 2 = 88
Branch analysis from position: 100
1 jumps found. (Code = 42) Position 1 = 109
Branch analysis from position: 109
2 jumps found. (Code = 44) Position 1 = 111, Position 2 = 104
Branch analysis from position: 111
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 104
2 jumps found. (Code = 44) Position 1 = 111, Position 2 = 104
Branch analysis from position: 111
Branch analysis from position: 104
Branch analysis from position: 88
2 jumps found. (Code = 44) Position 1 = 100, Position 2 = 88
Branch analysis from position: 100
Branch analysis from position: 88
Branch analysis from position: 14
1 jumps found. (Code = 42) Position 1 = 72
Branch analysis from position: 72
2 jumps found. (Code = 44) Position 1 = 75, Position 2 = 17
Branch analysis from position: 75
2 jumps found. (Code = 44) Position 1 = 79, Position 2 = 14
Branch analysis from position: 79
Branch analysis from position: 14
Branch analysis from position: 17
2 jumps found. (Code = 43) Position 1 = 53, Position 2 = 62
Branch analysis from position: 53
1 jumps found. (Code = 42) Position 1 = 70
Branch analysis from position: 70
2 jumps found. (Code = 44) Position 1 = 75, Position 2 = 17
Branch analysis from position: 75
Branch analysis from position: 17
Branch analysis from position: 62
2 jumps found. (Code = 44) Position 1 = 75, Position 2 = 17
Branch analysis from position: 75
Branch analysis from position: 17
Branch analysis from position: 6
2 jumps found. (Code = 44) Position 1 = 12, Position 2 = 6
Branch analysis from position: 12
Branch analysis from position: 6
filename:       /in/OkRnb
function name:  (null)
number of ops:  112
compiled vars:  !0 = $hotels, !1 = $totalHotelsNumber, !2 = $starCoef, !3 = $ratingCoef, !4 = $i, !5 = $j, !6 = $starDifference, !7 = $ratingToCompensate, !8 = $rating, !9 = $ratingDifference, !10 = $priceToCompensate, !11 = $price
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   11     1        ASSIGN                                                   !1, 2
   13     2        ASSIGN                                                   !2, 0.2
   14     3        ASSIGN                                                   !3, 2000
   16     4        ASSIGN                                                   !4, 0
          5      > JMP                                                      ->9
   17     6    >   ASSIGN_DIM                                               !0, 4
          7        OP_DATA                                                  0
   16     8        PRE_INC                                                  !4
          9    >   COUNT                                            ~19     !0
         10        IS_SMALLER                                               !4, ~19
         11      > JMPNZ                                                    ~20, ->6
   20    12    >   ASSIGN                                                   !4, 0
         13      > JMP                                                      ->76
   21    14    >   ADD                                              ~22     !4, 1
         15        ASSIGN                                                   !5, ~22
         16      > JMP                                                      ->72
   22    17    >   FETCH_DIM_R                                      ~24     !0, !4
         18        FETCH_DIM_R                                      ~25     ~24, 0
         19        CONCAT                                           ~26     'Comparing+', ~25
         20        CONCAT                                           ~27     ~26, '+and+'
         21        FETCH_DIM_R                                      ~28     !0, !5
         22        FETCH_DIM_R                                      ~29     ~28, 0
         23        CONCAT                                           ~30     ~27, ~29
         24        CONCAT                                           ~31     ~30, '...'
         25        CONCAT                                           ~32     ~31, '%0D%0A'
         26        ECHO                                                     ~32
   24    27        FETCH_DIM_R                                      ~33     !0, !4
         28        FETCH_DIM_R                                      ~34     ~33, 1
         29        FETCH_DIM_R                                      ~35     !0, !5
         30        FETCH_DIM_R                                      ~36     ~35, 1
         31        SUB                                              ~37     ~34, ~36
         32        ASSIGN                                                   !6, ~37
   25    33        MUL                                              ~39     !6, !2
         34        ASSIGN                                                   !7, ~39
   26    35        ASSIGN_OP                                     1          !8, !7
   28    36        FETCH_DIM_R                                      ~42     !0, !5
         37        FETCH_DIM_R                                      ~43     ~42, 2
         38        SUB                                              ~44     !8, ~43
         39        ASSIGN                                                   !9, ~44
   29    40        MUL                                              ~46     !9, !3
         41        ASSIGN                                                   !10, ~46
   30    42        ASSIGN_OP                                     2          !11, !10
   32    43        CONCAT                                           ~49     !11, '+VS+'
         44        FETCH_DIM_R                                      ~50     !0, !5
         45        FETCH_DIM_R                                      ~51     ~50, 2
         46        CONCAT                                           ~52     ~49, ~51
         47        CONCAT                                           ~53     ~52, '%0D%0A'
         48        ECHO                                                     ~53
   33    49        FETCH_DIM_R                                      ~54     !0, !5
         50        FETCH_DIM_R                                      ~55     ~54, 2
         51        IS_SMALLER                                               ~55, !11
         52      > JMPZ                                                     ~56, ->62
   34    53    >   FETCH_DIM_R                                      ~57     !0, !4
         54        FETCH_DIM_R                                      ~58     ~57, 0
         55        CONCAT                                           ~59     ~58, '+wins%21'
         56        CONCAT                                           ~60     ~59, '%0D%0A'
         57        ECHO                                                     ~60
   35    58        FETCH_DIM_RW                                     $61     !0, !4
         59        FETCH_DIM_RW                                     $62     $61, 4
         60        PRE_INC                                                  $62
         61      > JMP                                                      ->70
   37    62    >   FETCH_DIM_R                                      ~64     !0, !5
         63        FETCH_DIM_R                                      ~65     ~64, 0
         64        CONCAT                                           ~66     ~65, '+wins%21'
         65        CONCAT                                           ~67     ~66, '%0D%0A'
         66        ECHO                                                     ~67
   38    67        FETCH_DIM_RW                                     $68     !0, !5
         68        FETCH_DIM_RW                                     $69     $68, 4
         69        PRE_INC                                                  $69
   41    70    >   ECHO                                                     '%0D%0A----------%0D%0A'
   21    71        PRE_INC                                                  !5
         72    >   COUNT                                            ~72     !0
         73        IS_SMALLER                                               !5, ~72
         74      > JMPNZ                                                    ~73, ->17
   20    75    >   PRE_INC                                                  !4
         76    >   COUNT                                            ~75     !0
         77        IS_SMALLER                                               !4, ~75
         78      > JMPNZ                                                    ~76, ->14
   45    79    >   INIT_FCALL                                               'usort'
         80        SEND_REF                                                 !0
         81        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FOkRnb%3A45%240'
   47    82        SEND_VAL                                                 ~77
         83        DO_ICALL                                                 
   49    84        ECHO                                                     '%0D%0A----------%0D%0A'
   51    85        ECHO                                                     'Top%3A%0D%0A%0D%0A'
   52    86        ASSIGN                                                   !4, 0
         87      > JMP                                                      ->97
   53    88    >   FETCH_DIM_R                                      ~80     !0, !4
         89        FETCH_DIM_R                                      ~81     ~80, 0
         90        CONCAT                                           ~82     ~81, '%3A+'
         91        FETCH_DIM_R                                      ~83     !0, !4
         92        FETCH_DIM_R                                      ~84     ~83, 4
         93        CONCAT                                           ~85     ~82, ~84
         94        CONCAT                                           ~86     ~85, '%0D%0A'
         95        ECHO                                                     ~86
   52    96        PRE_INC                                                  !4
         97    >   COUNT                                            ~88     !0
         98        IS_SMALLER                                               !4, ~88
         99      > JMPNZ                                                    ~89, ->88
   56   100    >   ECHO                                                     '%0D%0A----------%0D%0A'
   57   101        ECHO                                                     'Finalists%3A%0D%0A%0D%0A'
   59   102        ASSIGN                                                   !4, 0
        103      > JMP                                                      ->109
   60   104    >   FETCH_DIM_R                                      ~91     !0, !4
        105        FETCH_DIM_R                                      ~92     ~91, 0
        106        CONCAT                                           ~93     ~92, '%0D%0A'
        107        ECHO                                                     ~93
   59   108        PRE_INC                                                  !4
        109    >   IS_SMALLER_OR_EQUAL                                      !4, 1
        110      > JMPNZ                                                    ~95, ->104
   61   111    > > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2FOkRnb%3A45%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/OkRnb
function name:  {closure}
number of ops:  7
compiled vars:  !0 = $hotelA, !1 = $hotelB
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   45     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   46     2        FETCH_DIM_R                                      ~2      !0, 4
          3        FETCH_DIM_R                                      ~3      !1, 4
          4        SUB                                              ~4      ~2, ~3
          5      > RETURN                                                   ~4
   47     6*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FOkRnb%3A45%240

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
163.4 ms | 1408 KiB | 15 Q