3v4l.org

run code in 300+ PHP versions simultaneously
<?php $tel1 = "32280907"; //8 $tel2 = "4832280907"; //10 //$tel3 = "04832280907"; //11 $tel4 = "554832280907"; //12 //$tel5 = "5504832280907"; //13 //$tel6 = "84253990"; //8 $tel7 = "984253990"; //9 $tel8 = "48984253990"; //11 //$tel9 = "048984253990"; //12 $tel10 = "5548984253990"; //13 //$tel11 = "55048984253990"; //14 $ftel1 = "3228-0907"; //8 $ftel2 = "48 3228-0907"; //10 $ftel4 = "55 48 3228-0907"; //12 $ftel7 = "98425-3990"; //9 $ftel8 = "48 98425-3990"; //11 $ftel10 = "55 48 98425-3990"; //13 $telefone = '5548984253990'; $tamTel = strlen($telefone); $pattern = ""; $retorno = ""; switch($tamTel) { case 8: //9999-9999 $pattern = '/(\d{4})(\d{4})(\d*)/'; $retorno = preg_replace($pattern, '$1-$2', $telefone); break; case 9: //99999-9999 $pattern = '/(\d{5})(\d{4})(\d*)/'; $retorno = preg_replace($pattern, '$1-$2', $telefone); break; case 10: //99 9999-9999 $pattern = '/(\d{2})(\d{4})(\d{4})(\d*)/'; $retorno = preg_replace($pattern, '($1) $2-$3', $telefone); break; case 11: //99 99999-9999 $pattern = '/(\d{2})(\d{5})(\d{4})(\d*)/'; $retorno = preg_replace($pattern, '($1) $2-$3', $telefone); break; case 12: //99 99 9999-9999 $pattern = '/(\d{2})(\d{2})(\d{4})(\d{4})(\d*)/'; $retorno = preg_replace($pattern, '$1 $2 $3-$4', $telefone); break; case 13: //99 99 99999-9999 $pattern = '/(\d{2})(\d{2})(\d{5})(\d{4})(\d*)/'; $retorno = preg_replace($pattern, '$1 $2 $3-$4', $telefone); break; } echo $retorno; //$pattern = '/(\d{2})(\d{4})(\d*)/'; //$telefoneN = preg_replace($pattern, '($1) $2-$3', $telefone);
Finding entry points
Branch analysis from position: 0
8 jumps found. (Code = 187) Position 1 = 31, Position 2 = 39, Position 3 = 47, Position 4 = 55, Position 5 = 63, Position 6 = 71, Position 7 = 79, Position 8 = 18
Branch analysis from position: 31
1 jumps found. (Code = 42) Position 1 = 79
Branch analysis from position: 79
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 39
1 jumps found. (Code = 42) Position 1 = 79
Branch analysis from position: 79
Branch analysis from position: 47
1 jumps found. (Code = 42) Position 1 = 79
Branch analysis from position: 79
Branch analysis from position: 55
1 jumps found. (Code = 42) Position 1 = 79
Branch analysis from position: 79
Branch analysis from position: 63
1 jumps found. (Code = 42) Position 1 = 79
Branch analysis from position: 79
Branch analysis from position: 71
1 jumps found. (Code = 42) Position 1 = 79
Branch analysis from position: 79
Branch analysis from position: 79
Branch analysis from position: 18
2 jumps found. (Code = 44) Position 1 = 20, Position 2 = 31
Branch analysis from position: 20
2 jumps found. (Code = 44) Position 1 = 22, Position 2 = 39
Branch analysis from position: 22
2 jumps found. (Code = 44) Position 1 = 24, Position 2 = 47
Branch analysis from position: 24
2 jumps found. (Code = 44) Position 1 = 26, Position 2 = 55
Branch analysis from position: 26
2 jumps found. (Code = 44) Position 1 = 28, Position 2 = 63
Branch analysis from position: 28
2 jumps found. (Code = 44) Position 1 = 30, Position 2 = 71
Branch analysis from position: 30
1 jumps found. (Code = 42) Position 1 = 79
Branch analysis from position: 79
Branch analysis from position: 71
Branch analysis from position: 63
Branch analysis from position: 55
Branch analysis from position: 47
Branch analysis from position: 39
Branch analysis from position: 31
filename:       /in/JnnWP
function name:  (null)
number of ops:  81
compiled vars:  !0 = $tel1, !1 = $tel2, !2 = $tel4, !3 = $tel7, !4 = $tel8, !5 = $tel10, !6 = $ftel1, !7 = $ftel2, !8 = $ftel4, !9 = $ftel7, !10 = $ftel8, !11 = $ftel10, !12 = $telefone, !13 = $tamTel, !14 = $pattern, !15 = $retorno
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, '32280907'
    3     1        ASSIGN                                                   !1, '4832280907'
    5     2        ASSIGN                                                   !2, '554832280907'
    8     3        ASSIGN                                                   !3, '984253990'
    9     4        ASSIGN                                                   !4, '48984253990'
   11     5        ASSIGN                                                   !5, '5548984253990'
   14     6        ASSIGN                                                   !6, '3228-0907'
   15     7        ASSIGN                                                   !7, '48+3228-0907'
   16     8        ASSIGN                                                   !8, '55+48+3228-0907'
   17     9        ASSIGN                                                   !9, '98425-3990'
   18    10        ASSIGN                                                   !10, '48+98425-3990'
   19    11        ASSIGN                                                   !11, '55+48+98425-3990'
   21    12        ASSIGN                                                   !12, '5548984253990'
   22    13        STRLEN                                           ~29     !12
         14        ASSIGN                                                   !13, ~29
   23    15        ASSIGN                                                   !14, ''
   24    16        ASSIGN                                                   !15, ''
   25    17      > SWITCH_LONG                                              !13, [ 8:->31, 9:->39, 10:->47, 11:->55, 12:->63, 13:->71, ], ->79
   26    18    >   IS_EQUAL                                                 !13, 8
         19      > JMPNZ                                                    ~33, ->31
   31    20    >   IS_EQUAL                                                 !13, 9
         21      > JMPNZ                                                    ~33, ->39
   36    22    >   IS_EQUAL                                                 !13, 10
         23      > JMPNZ                                                    ~33, ->47
   41    24    >   IS_EQUAL                                                 !13, 11
         25      > JMPNZ                                                    ~33, ->55
   46    26    >   IS_EQUAL                                                 !13, 12
         27      > JMPNZ                                                    ~33, ->63
   51    28    >   IS_EQUAL                                                 !13, 13
         29      > JMPNZ                                                    ~33, ->71
         30    > > JMP                                                      ->79
   28    31    >   ASSIGN                                                   !14, '%2F%28%5Cd%7B4%7D%29%28%5Cd%7B4%7D%29%28%5Cd%2A%29%2F'
   29    32        INIT_FCALL                                               'preg_replace'
         33        SEND_VAR                                                 !14
         34        SEND_VAL                                                 '%241-%242'
         35        SEND_VAR                                                 !12
         36        DO_ICALL                                         $35     
         37        ASSIGN                                                   !15, $35
   30    38      > JMP                                                      ->79
   33    39    >   ASSIGN                                                   !14, '%2F%28%5Cd%7B5%7D%29%28%5Cd%7B4%7D%29%28%5Cd%2A%29%2F'
   34    40        INIT_FCALL                                               'preg_replace'
         41        SEND_VAR                                                 !14
         42        SEND_VAL                                                 '%241-%242'
         43        SEND_VAR                                                 !12
         44        DO_ICALL                                         $38     
         45        ASSIGN                                                   !15, $38
   35    46      > JMP                                                      ->79
   38    47    >   ASSIGN                                                   !14, '%2F%28%5Cd%7B2%7D%29%28%5Cd%7B4%7D%29%28%5Cd%7B4%7D%29%28%5Cd%2A%29%2F'
   39    48        INIT_FCALL                                               'preg_replace'
         49        SEND_VAR                                                 !14
         50        SEND_VAL                                                 '%28%241%29+%242-%243'
         51        SEND_VAR                                                 !12
         52        DO_ICALL                                         $41     
         53        ASSIGN                                                   !15, $41
   40    54      > JMP                                                      ->79
   43    55    >   ASSIGN                                                   !14, '%2F%28%5Cd%7B2%7D%29%28%5Cd%7B5%7D%29%28%5Cd%7B4%7D%29%28%5Cd%2A%29%2F'
   44    56        INIT_FCALL                                               'preg_replace'
         57        SEND_VAR                                                 !14
         58        SEND_VAL                                                 '%28%241%29+%242-%243'
         59        SEND_VAR                                                 !12
         60        DO_ICALL                                         $44     
         61        ASSIGN                                                   !15, $44
   45    62      > JMP                                                      ->79
   48    63    >   ASSIGN                                                   !14, '%2F%28%5Cd%7B2%7D%29%28%5Cd%7B2%7D%29%28%5Cd%7B4%7D%29%28%5Cd%7B4%7D%29%28%5Cd%2A%29%2F'
   49    64        INIT_FCALL                                               'preg_replace'
         65        SEND_VAR                                                 !14
         66        SEND_VAL                                                 '%241+%242+%243-%244'
         67        SEND_VAR                                                 !12
         68        DO_ICALL                                         $47     
         69        ASSIGN                                                   !15, $47
   50    70      > JMP                                                      ->79
   53    71    >   ASSIGN                                                   !14, '%2F%28%5Cd%7B2%7D%29%28%5Cd%7B2%7D%29%28%5Cd%7B5%7D%29%28%5Cd%7B4%7D%29%28%5Cd%2A%29%2F'
   54    72        INIT_FCALL                                               'preg_replace'
         73        SEND_VAR                                                 !14
         74        SEND_VAL                                                 '%241+%242+%243-%244'
         75        SEND_VAR                                                 !12
         76        DO_ICALL                                         $50     
         77        ASSIGN                                                   !15, $50
   55    78      > JMP                                                      ->79
   58    79    >   ECHO                                                     !15
   60    80      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
167.03 ms | 1404 KiB | 15 Q