3v4l.org

run code in 500+ 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 = 8, Position 2 = 22
Branch analysis from position: 8
1 jumps found. (Code = 42) Position 1 = 23
Branch analysis from position: 23
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 22
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/LXVXN
function name:  (null)
number of ops:  24
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        FRAMELESS_ICALL_2                substr              ~4      !1, -1
          4        SEND_VAL                                                     ~4
          5        DO_ICALL                                             $5      
          6        ISSET_ISEMPTY_DIM_OBJ                             0          !0, $5
          7      > JMPZ                                                         ~6, ->22
    7     8    >   FRAMELESS_ICALL_3                substr              ~7      !1, 0
          9        OP_DATA                                                      -1
         10        INIT_FCALL                                                   'pow'
         11        SEND_VAL                                                     1000
         12        INIT_FCALL                                                   'strtoupper'
         13        FRAMELESS_ICALL_2                substr              ~8      !1, -1
         14        SEND_VAL                                                     ~8
         15        DO_ICALL                                             $9      
         16        FETCH_DIM_R                                          ~10     !0, $9
         17        SEND_VAL                                                     ~10
         18        DO_ICALL                                             $11     
         19        MUL                                                  ~12     $11, ~7
         20        ECHO                                                         ~12
    6    21      > JMP                                                          ->23
    9    22    >   ECHO                                                         !1
   10    23    > > RETURN                                                       1

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
170.44 ms | 3314 KiB | 15 Q