3v4l.org

run code in 500+ PHP versions simultaneously
<?php function toInt($size): int { // Remove the non-unit characters from the size. $unit = preg_replace('/[^bkmgtpezy]/i', '', $size); // Remove the non-numeric characters from the size. $size = preg_replace('/[^0-9\.]/', '', $size); if ($unit) { // Find the position of the unit in the ordered string which is the power // of magnitude to multiply a kilobyte by. return round($size * pow(1024, stripos('bkmgtpezy', $unit[0]))); } else { return round($size); } } var_dump(toInt('1 KB'));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/PmrWm
function name:  (null)
number of ops:  7
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   18     0  E >   INIT_FCALL                                                   'var_dump'
          1        INIT_FCALL                                                   'toint'
          2        SEND_VAL                                                     '1+KB'
          3        DO_FCALL                                          0  $0      
          4        SEND_VAR                                                     $0
          5        DO_ICALL                                                     
          6      > RETURN                                                       1

Function toint:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 8, Position 2 = 24
Branch analysis from position: 8
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 24
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/PmrWm
function name:  toInt
number of ops:  31
compiled vars:  !0 = $size, !1 = $unit
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   RECV                                                 !0      
    5     1        FRAMELESS_ICALL_3                preg_replace        ~2      '%2F%5B%5Ebkmgtpezy%5D%2Fi', ''
          2        OP_DATA                                                      !0
          3        ASSIGN                                                       !1, ~2
    7     4        FRAMELESS_ICALL_3                preg_replace        ~4      '%2F%5B%5E0-9%5C.%5D%2F', ''
          5        OP_DATA                                                      !0
          6        ASSIGN                                                       !0, ~4
    8     7      > JMPZ                                                         !1, ->24
   11     8    >   INIT_FCALL                                                   'round'
          9        INIT_FCALL                                                   'pow'
         10        SEND_VAL                                                     1024
         11        INIT_FCALL                                                   'stripos'
         12        SEND_VAL                                                     'bkmgtpezy'
         13        FETCH_DIM_R                                          ~6      !1, 0
         14        SEND_VAL                                                     ~6
         15        DO_ICALL                                             $7      
         16        SEND_VAR                                                     $7
         17        DO_ICALL                                             $8      
         18        MUL                                                  ~9      !0, $8
         19        SEND_VAL                                                     ~9
         20        DO_ICALL                                             $10     
         21        VERIFY_RETURN_TYPE                                           $10
         22      > RETURN                                                       $10
    8    23*       JMP                                                          ->29
   14    24    >   INIT_FCALL                                                   'round'
         25        SEND_VAR                                                     !0
         26        DO_ICALL                                             $11     
         27        VERIFY_RETURN_TYPE                                           $11
         28      > RETURN                                                       $11
   16    29*       VERIFY_RETURN_TYPE                                           
         30*     > RETURN                                                       null

End of function toint

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
166.06 ms | 3307 KiB | 18 Q