3v4l.org

run code in 300+ PHP versions simultaneously
<?php function formatPhoneNumber(string $phonenumber) { $phonenumber = str_replace([' ', '-', '.', '(', ')'], '', $phonenumber); if (strpos($phonenumber, '+') === 0) { return $phonenumber; } if (strlen($phonenumber) === 10 && strpos($phonenumber, '06') === 0) { return '+31' . ltrim($phonenumber, '0'); } return $phonenumber; } echo formatPhoneNumber('0031 (0) 6 123 45 678');
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/TXFYX
function name:  (null)
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   17     0  E >   INIT_FCALL                                               'formatphonenumber'
          1        SEND_VAL                                                 '0031+%280%29+6+123+45+678'
          2        DO_FCALL                                      0  $0      
          3        ECHO                                                     $0
          4      > RETURN                                                   1

Function formatphonenumber:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 13, Position 2 = 14
Branch analysis from position: 13
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 14
2 jumps found. (Code = 46) Position 1 = 17, Position 2 = 23
Branch analysis from position: 17
2 jumps found. (Code = 43) Position 1 = 24, Position 2 = 30
Branch analysis from position: 24
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 30
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 23
filename:       /in/TXFYX
function name:  formatPhoneNumber
number of ops:  32
compiled vars:  !0 = $phonenumber
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
    5     1        INIT_FCALL                                               'str_replace'
          2        SEND_VAL                                                 <array>
          3        SEND_VAL                                                 ''
          4        SEND_VAR                                                 !0
          5        DO_ICALL                                         $1      
          6        ASSIGN                                                   !0, $1
    7     7        INIT_FCALL                                               'strpos'
          8        SEND_VAR                                                 !0
          9        SEND_VAL                                                 '%2B'
         10        DO_ICALL                                         $3      
         11        IS_IDENTICAL                                             $3, 0
         12      > JMPZ                                                     ~4, ->14
    8    13    > > RETURN                                                   !0
   10    14    >   STRLEN                                           ~5      !0
         15        IS_IDENTICAL                                     ~6      ~5, 10
         16      > JMPZ_EX                                          ~6      ~6, ->23
         17    >   INIT_FCALL                                               'strpos'
         18        SEND_VAR                                                 !0
         19        SEND_VAL                                                 '06'
         20        DO_ICALL                                         $7      
         21        IS_IDENTICAL                                     ~8      $7, 0
         22        BOOL                                             ~6      ~8
         23    > > JMPZ                                                     ~6, ->30
   11    24    >   INIT_FCALL                                               'ltrim'
         25        SEND_VAR                                                 !0
         26        SEND_VAL                                                 '0'
         27        DO_ICALL                                         $9      
         28        CONCAT                                           ~10     '%2B31', $9
         29      > RETURN                                                   ~10
   14    30    > > RETURN                                                   !0
   15    31*     > RETURN                                                   null

End of function formatphonenumber

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
168.99 ms | 1403 KiB | 20 Q