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[$i][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 = $hotels[$i][2]+$ratingToCompensate; $ratingDifference = ($rating-$hotels[$j][2])*10; $priceToCompensate = $ratingDifference*$ratingCoef; $price = $hotels[$i][3]-$priceToCompensate; echo $price.' VS '.$hotels[$j][3]."\r\n"; if ( $price > $hotels[$j][3] ) { 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 $hotelB[4]-$hotelA[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 = 10
Branch analysis from position: 10
2 jumps found. (Code = 44) Position 1 = 13, Position 2 = 6
Branch analysis from position: 13
1 jumps found. (Code = 42) Position 1 = 84
Branch analysis from position: 84
2 jumps found. (Code = 44) Position 1 = 87, Position 2 = 15
Branch analysis from position: 87
1 jumps found. (Code = 42) Position 1 = 105
Branch analysis from position: 105
2 jumps found. (Code = 44) Position 1 = 108, Position 2 = 96
Branch analysis from position: 108
1 jumps found. (Code = 42) Position 1 = 117
Branch analysis from position: 117
2 jumps found. (Code = 44) Position 1 = 119, Position 2 = 112
Branch analysis from position: 119
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 112
2 jumps found. (Code = 44) Position 1 = 119, Position 2 = 112
Branch analysis from position: 119
Branch analysis from position: 112
Branch analysis from position: 96
2 jumps found. (Code = 44) Position 1 = 108, Position 2 = 96
Branch analysis from position: 108
Branch analysis from position: 96
Branch analysis from position: 15
1 jumps found. (Code = 42) Position 1 = 80
Branch analysis from position: 80
2 jumps found. (Code = 44) Position 1 = 83, Position 2 = 18
Branch analysis from position: 83
2 jumps found. (Code = 44) Position 1 = 87, Position 2 = 15
Branch analysis from position: 87
Branch analysis from position: 15
Branch analysis from position: 18
2 jumps found. (Code = 43) Position 1 = 61, Position 2 = 70
Branch analysis from position: 61
1 jumps found. (Code = 42) Position 1 = 78
Branch analysis from position: 78
2 jumps found. (Code = 44) Position 1 = 83, Position 2 = 18
Branch analysis from position: 83
Branch analysis from position: 18
Branch analysis from position: 70
2 jumps found. (Code = 44) Position 1 = 83, Position 2 = 18
Branch analysis from position: 83
Branch analysis from position: 18
Branch analysis from position: 6
2 jumps found. (Code = 44) Position 1 = 13, Position 2 = 6
Branch analysis from position: 13
Branch analysis from position: 6
filename:       /in/aHkhO
function name:  (null)
number of ops:  120
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                                                      ->10
   17     6    >   FETCH_DIM_W                                      $17     !0, !4
          7        ASSIGN_DIM                                               $17, 4
          8        OP_DATA                                                  0
   16     9        PRE_INC                                                  !4
         10    >   COUNT                                            ~20     !0
         11        IS_SMALLER                                               !4, ~20
         12      > JMPNZ                                                    ~21, ->6
   20    13    >   ASSIGN                                                   !4, 0
         14      > JMP                                                      ->84
   21    15    >   ADD                                              ~23     !4, 1
         16        ASSIGN                                                   !5, ~23
         17      > JMP                                                      ->80
   22    18    >   FETCH_DIM_R                                      ~25     !0, !4
         19        FETCH_DIM_R                                      ~26     ~25, 0
         20        CONCAT                                           ~27     'Comparing+', ~26
         21        CONCAT                                           ~28     ~27, '+and+'
         22        FETCH_DIM_R                                      ~29     !0, !5
         23        FETCH_DIM_R                                      ~30     ~29, 0
         24        CONCAT                                           ~31     ~28, ~30
         25        CONCAT                                           ~32     ~31, '...'
         26        CONCAT                                           ~33     ~32, '%0D%0A'
         27        ECHO                                                     ~33
   24    28        FETCH_DIM_R                                      ~34     !0, !4
         29        FETCH_DIM_R                                      ~35     ~34, 1
         30        FETCH_DIM_R                                      ~36     !0, !5
         31        FETCH_DIM_R                                      ~37     ~36, 1
         32        SUB                                              ~38     ~35, ~37
         33        ASSIGN                                                   !6, ~38
   25    34        MUL                                              ~40     !6, !2
         35        ASSIGN                                                   !7, ~40
   26    36        FETCH_DIM_R                                      ~42     !0, !4
         37        FETCH_DIM_R                                      ~43     ~42, 2
         38        ADD                                              ~44     ~43, !7
         39        ASSIGN                                                   !8, ~44
   28    40        FETCH_DIM_R                                      ~46     !0, !5
         41        FETCH_DIM_R                                      ~47     ~46, 2
         42        SUB                                              ~48     !8, ~47
         43        MUL                                              ~49     ~48, 10
         44        ASSIGN                                                   !9, ~49
   29    45        MUL                                              ~51     !9, !3
         46        ASSIGN                                                   !10, ~51
   30    47        FETCH_DIM_R                                      ~53     !0, !4
         48        FETCH_DIM_R                                      ~54     ~53, 3
         49        SUB                                              ~55     ~54, !10
         50        ASSIGN                                                   !11, ~55
   32    51        CONCAT                                           ~57     !11, '+VS+'
         52        FETCH_DIM_R                                      ~58     !0, !5
         53        FETCH_DIM_R                                      ~59     ~58, 3
         54        CONCAT                                           ~60     ~57, ~59
         55        CONCAT                                           ~61     ~60, '%0D%0A'
         56        ECHO                                                     ~61
   33    57        FETCH_DIM_R                                      ~62     !0, !5
         58        FETCH_DIM_R                                      ~63     ~62, 3
         59        IS_SMALLER                                               ~63, !11
         60      > JMPZ                                                     ~64, ->70
   34    61    >   FETCH_DIM_R                                      ~65     !0, !4
         62        FETCH_DIM_R                                      ~66     ~65, 0
         63        CONCAT                                           ~67     ~66, '+wins%21'
         64        CONCAT                                           ~68     ~67, '%0D%0A'
         65        ECHO                                                     ~68
   35    66        FETCH_DIM_RW                                     $69     !0, !4
         67        FETCH_DIM_RW                                     $70     $69, 4
         68        PRE_INC                                                  $70
         69      > JMP                                                      ->78
   37    70    >   FETCH_DIM_R                                      ~72     !0, !5
         71        FETCH_DIM_R                                      ~73     ~72, 0
         72        CONCAT                                           ~74     ~73, '+wins%21'
         73        CONCAT                                           ~75     ~74, '%0D%0A'
         74        ECHO                                                     ~75
   38    75        FETCH_DIM_RW                                     $76     !0, !5
         76        FETCH_DIM_RW                                     $77     $76, 4
         77        PRE_INC                                                  $77
   41    78    >   ECHO                                                     '%0D%0A----------%0D%0A'
   21    79        PRE_INC                                                  !5
         80    >   COUNT                                            ~80     !0
         81        IS_SMALLER                                               !5, ~80
         82      > JMPNZ                                                    ~81, ->18
   20    83    >   PRE_INC                                                  !4
         84    >   COUNT                                            ~83     !0
         85        IS_SMALLER                                               !4, ~83
         86      > JMPNZ                                                    ~84, ->15
   45    87    >   INIT_FCALL                                               'usort'
         88        SEND_REF                                                 !0
         89        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FaHkhO%3A45%240'
   47    90        SEND_VAL                                                 ~85
         91        DO_ICALL                                                 
   49    92        ECHO                                                     '%0D%0A----------%0D%0A'
   51    93        ECHO                                                     'Top%3A%0D%0A%0D%0A'
   52    94        ASSIGN                                                   !4, 0
         95      > JMP                                                      ->105
   53    96    >   FETCH_DIM_R                                      ~88     !0, !4
         97        FETCH_DIM_R                                      ~89     ~88, 0
         98        CONCAT                                           ~90     ~89, '%3A+'
         99        FETCH_DIM_R                                      ~91     !0, !4
        100        FETCH_DIM_R                                      ~92     ~91, 4
        101        CONCAT                                           ~93     ~90, ~92
        102        CONCAT                                           ~94     ~93, '%0D%0A'
        103        ECHO                                                     ~94
   52   104        PRE_INC                                                  !4
        105    >   COUNT                                            ~96     !0
        106        IS_SMALLER                                               !4, ~96
        107      > JMPNZ                                                    ~97, ->96
   56   108    >   ECHO                                                     '%0D%0A----------%0D%0A'
   57   109        ECHO                                                     'Finalists%3A%0D%0A%0D%0A'
   59   110        ASSIGN                                                   !4, 0
        111      > JMP                                                      ->117
   60   112    >   FETCH_DIM_R                                      ~99     !0, !4
        113        FETCH_DIM_R                                      ~100    ~99, 0
        114        CONCAT                                           ~101    ~100, '%0D%0A'
        115        ECHO                                                     ~101
   59   116        PRE_INC                                                  !4
        117    >   IS_SMALLER_OR_EQUAL                                      !4, 1
        118      > JMPNZ                                                    ~103, ->112
   61   119    > > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2FaHkhO%3A45%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/aHkhO
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      !1, 4
          3        FETCH_DIM_R                                      ~3      !0, 4
          4        SUB                                              ~4      ~2, ~3
          5      > RETURN                                                   ~4
   47     6*     > RETURN                                                   null

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

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
169.44 ms | 1408 KiB | 15 Q