3v4l.org

run code in 300+ PHP versions simultaneously
<?php function formatPhoneNumber(string $phonenumber) { $phonenumber = str_replace([' ', '-', '.', '(', ')'], '', $phonenumber); if (strpos($phonenumber, '00') === 0) { $phonenumber = '+' . substr($phonenumber, 2); } if (strpos($phonenumber, '+310') === 0) { $phonenumber = '+31' . substr($phonenumber, 4); } if (strpos($phonenumber, '+') === 0) { return $phonenumber; } if (strlen($phonenumber) === 10 && strpos($phonenumber, '06') === 0) { return '+31' . ltrim($phonenumber, '0'); } return $phonenumber; } echo formatPhoneNumber('+31 (0) 6 123 45 678');
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Ou1Sq
function name:  (null)
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   23     0  E >   INIT_FCALL                                               'formatphonenumber'
          1        SEND_VAL                                                 '%2B31+%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 = 19
Branch analysis from position: 13
2 jumps found. (Code = 43) Position 1 = 25, Position 2 = 31
Branch analysis from position: 25
2 jumps found. (Code = 43) Position 1 = 37, Position 2 = 38
Branch analysis from position: 37
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 38
2 jumps found. (Code = 46) Position 1 = 41, Position 2 = 47
Branch analysis from position: 41
2 jumps found. (Code = 43) Position 1 = 48, Position 2 = 54
Branch analysis from position: 48
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 54
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 47
Branch analysis from position: 31
Branch analysis from position: 19
filename:       /in/Ou1Sq
function name:  formatPhoneNumber
number of ops:  56
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
    6     7        INIT_FCALL                                               'strpos'
          8        SEND_VAR                                                 !0
          9        SEND_VAL                                                 '00'
         10        DO_ICALL                                         $3      
         11        IS_IDENTICAL                                             $3, 0
         12      > JMPZ                                                     ~4, ->19
    7    13    >   INIT_FCALL                                               'substr'
         14        SEND_VAR                                                 !0
         15        SEND_VAL                                                 2
         16        DO_ICALL                                         $5      
         17        CONCAT                                           ~6      '%2B', $5
         18        ASSIGN                                                   !0, ~6
    9    19    >   INIT_FCALL                                               'strpos'
         20        SEND_VAR                                                 !0
         21        SEND_VAL                                                 '%2B310'
         22        DO_ICALL                                         $8      
         23        IS_IDENTICAL                                             $8, 0
         24      > JMPZ                                                     ~9, ->31
   10    25    >   INIT_FCALL                                               'substr'
         26        SEND_VAR                                                 !0
         27        SEND_VAL                                                 4
         28        DO_ICALL                                         $10     
         29        CONCAT                                           ~11     '%2B31', $10
         30        ASSIGN                                                   !0, ~11
   13    31    >   INIT_FCALL                                               'strpos'
         32        SEND_VAR                                                 !0
         33        SEND_VAL                                                 '%2B'
         34        DO_ICALL                                         $13     
         35        IS_IDENTICAL                                             $13, 0
         36      > JMPZ                                                     ~14, ->38
   14    37    > > RETURN                                                   !0
   16    38    >   STRLEN                                           ~15     !0
         39        IS_IDENTICAL                                     ~16     ~15, 10
         40      > JMPZ_EX                                          ~16     ~16, ->47
         41    >   INIT_FCALL                                               'strpos'
         42        SEND_VAR                                                 !0
         43        SEND_VAL                                                 '06'
         44        DO_ICALL                                         $17     
         45        IS_IDENTICAL                                     ~18     $17, 0
         46        BOOL                                             ~16     ~18
         47    > > JMPZ                                                     ~16, ->54
   17    48    >   INIT_FCALL                                               'ltrim'
         49        SEND_VAR                                                 !0
         50        SEND_VAL                                                 '0'
         51        DO_ICALL                                         $19     
         52        CONCAT                                           ~20     '%2B31', $19
         53      > RETURN                                                   ~20
   20    54    > > RETURN                                                   !0
   21    55*     > RETURN                                                   null

End of function formatphonenumber

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
175.84 ms | 1394 KiB | 22 Q