3v4l.org

run code in 300+ PHP versions simultaneously
<?php function determineRank($input) { // valor retornado caso $input seja maior que todos os $ranks $default = 'Rainbow'; $ranks = [ 50 => 'Descolorido', 100 => 'Azul Bebê', 200 => 'Roxo Bacon', 300 => 'Verde ET', 500 => 'Marrom Madeira', 700 => 'Laranja Power', 900 => 'Vermelho Killer', 1500 => 'Rosa Piriguete', 1700 => 'Amarelo Bobba', 2000 => 'Turquesa Maravilha', 2300 => 'Gótica Má', 2500 => 'Ametista Destruidor', 2700 => 'Esmeralda Divindade', 3000 => 'Púrpura Star', 3500 => 'Dourado Rei', ]; foreach ($ranks as $rank => $value) { if ($input <= $rank) { return $value; } } return $default; } // Exemplo $i = 0; do { $input = rand(45, 3600); echo $input . ' - ' . determineRank($input) . PHP_EOL; } while(++$i < 20);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 44) Position 1 = 16, Position 2 = 1
Branch analysis from position: 16
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 1
filename:       /in/0D3Vs
function name:  (null)
number of ops:  17
compiled vars:  !0 = $i, !1 = $input
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   34     0  E >   ASSIGN                                                   !0, 0
   36     1    >   INIT_FCALL                                               'rand'
          2        SEND_VAL                                                 45
          3        SEND_VAL                                                 3600
          4        DO_ICALL                                         $3      
          5        ASSIGN                                                   !1, $3
   37     6        CONCAT                                           ~5      !1, '+-+'
          7        INIT_FCALL                                               'determinerank'
          8        SEND_VAR                                                 !1
          9        DO_FCALL                                      0  $6      
         10        CONCAT                                           ~7      ~5, $6
         11        CONCAT                                           ~8      ~7, '%0A'
         12        ECHO                                                     ~8
   38    13        PRE_INC                                          ~9      !0
         14        IS_SMALLER                                               ~9, 20
         15      > JMPNZ                                                    ~10, ->1
         16    > > RETURN                                                   1

Function determinerank:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 4, Position 2 = 11
Branch analysis from position: 4
2 jumps found. (Code = 78) Position 1 = 5, Position 2 = 11
Branch analysis from position: 5
2 jumps found. (Code = 43) Position 1 = 8, Position 2 = 10
Branch analysis from position: 8
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 10
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 11
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 11
filename:       /in/0D3Vs
function name:  determineRank
number of ops:  14
compiled vars:  !0 = $input, !1 = $default, !2 = $ranks, !3 = $value, !4 = $rank
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
    5     1        ASSIGN                                                   !1, 'Rainbow'
    6     2        ASSIGN                                                   !2, <array>
   24     3      > FE_RESET_R                                       $7      !2, ->11
          4    > > FE_FETCH_R                                       ~8      $7, !3, ->11
          5    >   ASSIGN                                                   !4, ~8
   25     6        IS_SMALLER_OR_EQUAL                                      !0, !4
          7      > JMPZ                                                     ~10, ->10
   26     8    >   FE_FREE                                                  $7
          9      > RETURN                                                   !3
   24    10    > > JMP                                                      ->4
         11    >   FE_FREE                                                  $7
   30    12      > RETURN                                                   !1
   31    13*     > RETURN                                                   null

End of function determinerank

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
140.35 ms | 1454 KiB | 15 Q