3v4l.org

run code in 300+ PHP versions simultaneously
<?php $arr = ["K" => 1 ,"M" => 2, "T" => 3]; $input = "12.2K"; if(isset($arr[strtoupper(substr($input, -1))])){ echo substr($input,0,-1) * pow(1000, $arr[strtoupper(substr($input, -1))]); }else{ echo $input; }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 11, Position 2 = 31
Branch analysis from position: 11
1 jumps found. (Code = 42) Position 1 = 32
Branch analysis from position: 32
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 31
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/LXVXN
function name:  (null)
number of ops:  33
compiled vars:  !0 = $arr, !1 = $input
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
    5     1        ASSIGN                                                   !1, '12.2K'
    6     2        INIT_FCALL                                               'strtoupper'
          3        INIT_FCALL                                               'substr'
          4        SEND_VAR                                                 !1
          5        SEND_VAL                                                 -1
          6        DO_ICALL                                         $4      
          7        SEND_VAR                                                 $4
          8        DO_ICALL                                         $5      
          9        ISSET_ISEMPTY_DIM_OBJ                         0          !0, $5
         10      > JMPZ                                                     ~6, ->31
    7    11    >   INIT_FCALL                                               'substr'
         12        SEND_VAR                                                 !1
         13        SEND_VAL                                                 0
         14        SEND_VAL                                                 -1
         15        DO_ICALL                                         $7      
         16        INIT_FCALL                                               'pow'
         17        SEND_VAL                                                 1000
         18        INIT_FCALL                                               'strtoupper'
         19        INIT_FCALL                                               'substr'
         20        SEND_VAR                                                 !1
         21        SEND_VAL                                                 -1
         22        DO_ICALL                                         $8      
         23        SEND_VAR                                                 $8
         24        DO_ICALL                                         $9      
         25        FETCH_DIM_R                                      ~10     !0, $9
         26        SEND_VAL                                                 ~10
         27        DO_ICALL                                         $11     
         28        MUL                                              ~12     $7, $11
         29        ECHO                                                     ~12
    6    30      > JMP                                                      ->32
    9    31    >   ECHO                                                     !1
   10    32    > > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
147.04 ms | 1003 KiB | 16 Q