3v4l.org

run code in 300+ PHP versions simultaneously
<?php echo formatsMobileNumber('+33631063771', 33).\n; echo formatsMobileNumber('+330631063771', 33); echo formatsMobileNumber('+49631063771', 49); echo formatsMobileNumber('0049631063771', 49); echo formatsMobileNumber('00390631063771', 39); echo formatsMobileNumber('0631063771', 33); echo formatsMobileNumber('631063771', 39); function formatsMobileNumber($mobileNumber, $countryCode) { $mobileNumber = str_replace(' ', '', $mobileNumber); if (strpos($mobileNumber, '+') === false) { if (strpos($mobileNumber, '00') === 0) { $mobileNumber = substr($mobileNumber, 2); } else { if (strpos($mobileNumber, '0') === 0) { $mobileNumber = substr($mobileNumber, 1); } $mobileNumber = $countryCode . $mobileNumber; } } else { $mobileNumber = substr($mobileNumber, 1); } $splitCountryCode = explode($countryCode, $mobileNumber); if (strpos($splitCountryCode[1], '0') === 0) { $arrayNumber = explode('0', $mobileNumber, 2); $mobileNumber = implode($arrayNumber); } return $mobileNumber; }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Xnmlc
function name:  (null)
number of ops:  38
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   INIT_FCALL_BY_NAME                                       'formatsMobileNumber'
          1        SEND_VAL_EX                                              '%2B33631063771'
          2        SEND_VAL_EX                                              33
          3        DO_FCALL                                      0  $0      
          4        FETCH_CONSTANT                                   ~1      'n'
          5        CONCAT                                           ~2      $0, ~1
          6        ECHO                                                     ~2
    4     7        INIT_FCALL_BY_NAME                                       'formatsMobileNumber'
          8        SEND_VAL_EX                                              '%2B330631063771'
          9        SEND_VAL_EX                                              33
         10        DO_FCALL                                      0  $3      
         11        ECHO                                                     $3
    5    12        INIT_FCALL_BY_NAME                                       'formatsMobileNumber'
         13        SEND_VAL_EX                                              '%2B49631063771'
         14        SEND_VAL_EX                                              49
         15        DO_FCALL                                      0  $4      
         16        ECHO                                                     $4
    6    17        INIT_FCALL_BY_NAME                                       'formatsMobileNumber'
         18        SEND_VAL_EX                                              '0049631063771'
         19        SEND_VAL_EX                                              49
         20        DO_FCALL                                      0  $5      
         21        ECHO                                                     $5
    7    22        INIT_FCALL_BY_NAME                                       'formatsMobileNumber'
         23        SEND_VAL_EX                                              '00390631063771'
         24        SEND_VAL_EX                                              39
         25        DO_FCALL                                      0  $6      
         26        ECHO                                                     $6
    8    27        INIT_FCALL_BY_NAME                                       'formatsMobileNumber'
         28        SEND_VAL_EX                                              '0631063771'
         29        SEND_VAL_EX                                              33
         30        DO_FCALL                                      0  $7      
         31        ECHO                                                     $7
    9    32        INIT_FCALL_BY_NAME                                       'formatsMobileNumber'
         33        SEND_VAL_EX                                              '631063771'
         34        SEND_VAL_EX                                              39
         35        DO_FCALL                                      0  $8      
         36        ECHO                                                     $8
   37    37      > RETURN                                                   1

Function formatsmobilenumber:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 14, Position 2 = 40
Branch analysis from position: 14
2 jumps found. (Code = 43) Position 1 = 20, Position 2 = 26
Branch analysis from position: 20
1 jumps found. (Code = 42) Position 1 = 39
Branch analysis from position: 39
1 jumps found. (Code = 42) Position 1 = 45
Branch analysis from position: 45
2 jumps found. (Code = 43) Position 1 = 57, Position 2 = 67
Branch analysis from position: 57
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 67
Branch analysis from position: 26
2 jumps found. (Code = 43) Position 1 = 32, Position 2 = 37
Branch analysis from position: 32
1 jumps found. (Code = 42) Position 1 = 45
Branch analysis from position: 45
Branch analysis from position: 37
Branch analysis from position: 40
2 jumps found. (Code = 43) Position 1 = 57, Position 2 = 67
Branch analysis from position: 57
Branch analysis from position: 67
filename:       /in/Xnmlc
function name:  formatsMobileNumber
number of ops:  69
compiled vars:  !0 = $mobileNumber, !1 = $countryCode, !2 = $splitCountryCode, !3 = $arrayNumber
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   12     2        INIT_FCALL                                               'str_replace'
          3        SEND_VAL                                                 '+'
          4        SEND_VAL                                                 ''
          5        SEND_VAR                                                 !0
          6        DO_ICALL                                         $4      
          7        ASSIGN                                                   !0, $4
   14     8        INIT_FCALL                                               'strpos'
          9        SEND_VAR                                                 !0
         10        SEND_VAL                                                 '%2B'
         11        DO_ICALL                                         $6      
         12        TYPE_CHECK                                    4          $6
         13      > JMPZ                                                     ~7, ->40
   15    14    >   INIT_FCALL                                               'strpos'
         15        SEND_VAR                                                 !0
         16        SEND_VAL                                                 '00'
         17        DO_ICALL                                         $8      
         18        IS_IDENTICAL                                             $8, 0
         19      > JMPZ                                                     ~9, ->26
   16    20    >   INIT_FCALL                                               'substr'
         21        SEND_VAR                                                 !0
         22        SEND_VAL                                                 2
         23        DO_ICALL                                         $10     
         24        ASSIGN                                                   !0, $10
         25      > JMP                                                      ->39
   19    26    >   INIT_FCALL                                               'strpos'
         27        SEND_VAR                                                 !0
         28        SEND_VAL                                                 '0'
         29        DO_ICALL                                         $12     
         30        IS_IDENTICAL                                             $12, 0
         31      > JMPZ                                                     ~13, ->37
   20    32    >   INIT_FCALL                                               'substr'
         33        SEND_VAR                                                 !0
         34        SEND_VAL                                                 1
         35        DO_ICALL                                         $14     
         36        ASSIGN                                                   !0, $14
   23    37    >   CONCAT                                           ~16     !1, !0
         38        ASSIGN                                                   !0, ~16
         39    > > JMP                                                      ->45
   26    40    >   INIT_FCALL                                               'substr'
         41        SEND_VAR                                                 !0
         42        SEND_VAL                                                 1
         43        DO_ICALL                                         $18     
         44        ASSIGN                                                   !0, $18
   29    45    >   INIT_FCALL                                               'explode'
         46        SEND_VAR                                                 !1
         47        SEND_VAR                                                 !0
         48        DO_ICALL                                         $20     
         49        ASSIGN                                                   !2, $20
   31    50        INIT_FCALL                                               'strpos'
         51        FETCH_DIM_R                                      ~22     !2, 1
         52        SEND_VAL                                                 ~22
         53        SEND_VAL                                                 '0'
         54        DO_ICALL                                         $23     
         55        IS_IDENTICAL                                             $23, 0
         56      > JMPZ                                                     ~24, ->67
   32    57    >   INIT_FCALL                                               'explode'
         58        SEND_VAL                                                 '0'
         59        SEND_VAR                                                 !0
         60        SEND_VAL                                                 2
         61        DO_ICALL                                         $25     
         62        ASSIGN                                                   !3, $25
   33    63        INIT_FCALL                                               'implode'
         64        SEND_VAR                                                 !3
         65        DO_ICALL                                         $27     
         66        ASSIGN                                                   !0, $27
   36    67    > > RETURN                                                   !0
   37    68*     > RETURN                                                   null

End of function formatsmobilenumber

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
150.91 ms | 1404 KiB | 23 Q