3v4l.org

run code in 300+ PHP versions simultaneously
<?php var_dump(stringToEnglishNumber('-214-277. 4404-', ', ')); function stringToEnglishNumber($string, $separator = ' ') { $sanitized = preg_replace("/[^\-0-9,. ]/", '', $string); $split = str_split($sanitized); if (empty($split)) { return $string; } if ($split[0] == '-') { $split[0] = 'negative'; } $convert = [ '-' => 'dash', '.' => 'dot', ' ' => 'space', ]; foreach ($split as $key => $char) { if (array_key_exists($char, $convert)) { $split[$key] = $convert[$char]; } } return implode("{$separator}", $split); }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/fTnKJ
function name:  (null)
number of ops:  8
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   INIT_FCALL                                               'var_dump'
          1        INIT_FCALL_BY_NAME                                       'stringToEnglishNumber'
          2        SEND_VAL_EX                                              '-214-277.+4404-'
          3        SEND_VAL_EX                                              '%2C+'
          4        DO_FCALL                                      0  $0      
          5        SEND_VAR                                                 $0
          6        DO_ICALL                                                 
   33     7      > RETURN                                                   1

Function stringtoenglishnumber:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 14, Position 2 = 15
Branch analysis from position: 14
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 15
2 jumps found. (Code = 43) Position 1 = 18, Position 2 = 20
Branch analysis from position: 18
2 jumps found. (Code = 77) Position 1 = 22, Position 2 = 30
Branch analysis from position: 22
2 jumps found. (Code = 78) Position 1 = 23, Position 2 = 30
Branch analysis from position: 23
2 jumps found. (Code = 43) Position 1 = 26, Position 2 = 29
Branch analysis from position: 26
1 jumps found. (Code = 42) Position 1 = 22
Branch analysis from position: 22
Branch analysis from position: 29
Branch analysis from position: 30
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 30
Branch analysis from position: 20
filename:       /in/fTnKJ
function name:  stringToEnglishNumber
number of ops:  38
compiled vars:  !0 = $string, !1 = $separator, !2 = $sanitized, !3 = $split, !4 = $convert, !5 = $char, !6 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   RECV                                             !0      
          1        RECV_INIT                                        !1      '+'
    8     2        INIT_FCALL                                               'preg_replace'
          3        SEND_VAL                                                 '%2F%5B%5E%5C-0-9%2C.+%5D%2F'
          4        SEND_VAL                                                 ''
          5        SEND_VAR                                                 !0
          6        DO_ICALL                                         $7      
          7        ASSIGN                                                   !2, $7
   10     8        INIT_FCALL                                               'str_split'
          9        SEND_VAR                                                 !2
         10        DO_ICALL                                         $9      
         11        ASSIGN                                                   !3, $9
   12    12        ISSET_ISEMPTY_CV                                         !3
         13      > JMPZ                                                     ~11, ->15
   13    14    > > RETURN                                                   !0
   16    15    >   FETCH_DIM_R                                      ~12     !3, 0
         16        IS_EQUAL                                                 ~12, '-'
         17      > JMPZ                                                     ~13, ->20
   17    18    >   ASSIGN_DIM                                               !3, 0
         19        OP_DATA                                                  'negative'
   20    20    >   ASSIGN                                                   !4, <array>
   26    21      > FE_RESET_R                                       $16     !3, ->30
         22    > > FE_FETCH_R                                       ~17     $16, !5, ->30
         23    >   ASSIGN                                                   !6, ~17
   27    24        ARRAY_KEY_EXISTS                                         !5, !4
         25      > JMPZ                                                     ~19, ->29
   28    26    >   FETCH_DIM_R                                      ~21     !4, !5
         27        ASSIGN_DIM                                               !3, !6
         28        OP_DATA                                                  ~21
   26    29    > > JMP                                                      ->22
         30    >   FE_FREE                                                  $16
   32    31        INIT_FCALL                                               'implode'
         32        CAST                                          6  ~22     !1
         33        SEND_VAL                                                 ~22
         34        SEND_VAR                                                 !3
         35        DO_ICALL                                         $23     
         36      > RETURN                                                   $23
   33    37*     > RETURN                                                   null

End of function stringtoenglishnumber

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
183.45 ms | 1392 KiB | 21 Q