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

Function %00%7Bclosure%7D%2Fin%2FKLaZr%3A45%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/KLaZr
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%2FKLaZr%3A45%240

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
169.19 ms | 1400 KiB | 15 Q