3v4l.org

run code in 300+ PHP versions simultaneously
<?php function tofloat($num) { $dotPos = strrpos($num, '.'); $commaPos = strrpos($num, ','); $sep = (($dotPos > $commaPos) && $dotPos) ? $dotPos : ((($commaPos > $dotPos) && $commaPos) ? $commaPos : false); if (!$sep) { return floatval(preg_replace("/[^0-9]/", "", $num)); } return floatval( preg_replace("/[^0-9]/", "", substr($num, 0, $sep)) . '.' . preg_replace("/[^0-9]/", "", substr($num, $sep+1, strlen($num))) ); } echo tofloat('ff324,243,32') ;
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/TOqnp
function name:  (null)
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   19     0  E >   INIT_FCALL                                               'tofloat'
          1        SEND_VAL                                                 'ff324%2C243%2C32'
          2        DO_FCALL                                      0  $0      
          3        ECHO                                                     $0
          4      > RETURN                                                   1

Function tofloat:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 46) Position 1 = 13, Position 2 = 14
Branch analysis from position: 13
2 jumps found. (Code = 43) Position 1 = 15, Position 2 = 17
Branch analysis from position: 15
1 jumps found. (Code = 42) Position 1 = 25
Branch analysis from position: 25
2 jumps found. (Code = 43) Position 1 = 28, Position 2 = 35
Branch analysis from position: 28
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 35
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 17
2 jumps found. (Code = 46) Position 1 = 19, Position 2 = 20
Branch analysis from position: 19
2 jumps found. (Code = 43) Position 1 = 21, Position 2 = 23
Branch analysis from position: 21
1 jumps found. (Code = 42) Position 1 = 24
Branch analysis from position: 24
2 jumps found. (Code = 43) Position 1 = 28, Position 2 = 35
Branch analysis from position: 28
Branch analysis from position: 35
Branch analysis from position: 23
2 jumps found. (Code = 43) Position 1 = 28, Position 2 = 35
Branch analysis from position: 28
Branch analysis from position: 35
Branch analysis from position: 20
Branch analysis from position: 14
filename:       /in/TOqnp
function name:  tofloat
number of ops:  62
compiled vars:  !0 = $num, !1 = $dotPos, !2 = $commaPos, !3 = $sep
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   RECV                                             !0      
    3     1        INIT_FCALL                                               'strrpos'
          2        SEND_VAR                                                 !0
          3        SEND_VAL                                                 '.'
          4        DO_ICALL                                         $4      
          5        ASSIGN                                                   !1, $4
    4     6        INIT_FCALL                                               'strrpos'
          7        SEND_VAR                                                 !0
          8        SEND_VAL                                                 '%2C'
          9        DO_ICALL                                         $6      
         10        ASSIGN                                                   !2, $6
    5    11        IS_SMALLER                                       ~8      !2, !1
         12      > JMPZ_EX                                          ~8      ~8, ->14
         13    >   BOOL                                             ~8      !1
         14    > > JMPZ                                                     ~8, ->17
         15    >   QM_ASSIGN                                        ~9      !1
         16      > JMP                                                      ->25
    6    17    >   IS_SMALLER                                       ~10     !1, !2
         18      > JMPZ_EX                                          ~10     ~10, ->20
         19    >   BOOL                                             ~10     !2
         20    > > JMPZ                                                     ~10, ->23
         21    >   QM_ASSIGN                                        ~11     !2
         22      > JMP                                                      ->24
         23    >   QM_ASSIGN                                        ~11     <false>
         24    >   QM_ASSIGN                                        ~9      ~11
    5    25    >   ASSIGN                                                   !3, ~9
    8    26        BOOL_NOT                                         ~13     !3
         27      > JMPZ                                                     ~13, ->35
    9    28    >   INIT_FCALL                                               'preg_replace'
         29        SEND_VAL                                                 '%2F%5B%5E0-9%5D%2F'
         30        SEND_VAL                                                 ''
         31        SEND_VAR                                                 !0
         32        DO_ICALL                                         $14     
         33        CAST                                          5  ~15     $14
         34      > RETURN                                                   ~15
   13    35    >   INIT_FCALL                                               'preg_replace'
         36        SEND_VAL                                                 '%2F%5B%5E0-9%5D%2F'
         37        SEND_VAL                                                 ''
         38        INIT_FCALL                                               'substr'
         39        SEND_VAR                                                 !0
         40        SEND_VAL                                                 0
         41        SEND_VAR                                                 !3
         42        DO_ICALL                                         $16     
         43        SEND_VAR                                                 $16
         44        DO_ICALL                                         $17     
         45        CONCAT                                           ~18     $17, '.'
   14    46        INIT_FCALL                                               'preg_replace'
         47        SEND_VAL                                                 '%2F%5B%5E0-9%5D%2F'
         48        SEND_VAL                                                 ''
         49        INIT_FCALL                                               'substr'
         50        SEND_VAR                                                 !0
         51        ADD                                              ~19     !3, 1
         52        SEND_VAL                                                 ~19
         53        STRLEN                                           ~20     !0
         54        SEND_VAL                                                 ~20
         55        DO_ICALL                                         $21     
         56        SEND_VAR                                                 $21
         57        DO_ICALL                                         $22     
         58        CONCAT                                           ~23     ~18, $22
         59        CAST                                          5  ~24     ~23
         60      > RETURN                                                   ~24
   16    61*     > RETURN                                                   null

End of function tofloat

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
159.12 ms | 1403 KiB | 20 Q