3v4l.org

run code in 300+ PHP versions simultaneously
<?php $numbers = explode("\n", '(111) 222-3333 ((111) 222-3333 1112223333 111 222-3333 111-222-3333 (111)2223333 +11234567890 1-8002353551 123-456-7890 -Hello! +1 - 1234567890 '); foreach($numbers as $number) { print preg_replace('~.*(\d{3})[^\d]*(\d{3})[^\d]*(\d{4}).*~', '($1) $2-$3', $number). "\n"; }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 6, Position 2 = 15
Branch analysis from position: 6
2 jumps found. (Code = 78) Position 1 = 7, Position 2 = 15
Branch analysis from position: 7
1 jumps found. (Code = 42) Position 1 = 6
Branch analysis from position: 6
Branch analysis from position: 15
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 15
filename:       /in/iruSH
function name:  (null)
number of ops:  17
compiled vars:  !0 = $numbers, !1 = $number
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   INIT_FCALL                                               'explode'
          1        SEND_VAL                                                 '%0A'
          2        SEND_VAL                                                 '%28111%29+222-3333%0A%28%28111%29+222-3333%0A1112223333%0A111+222-3333%0A111-222-3333%0A%28111%292223333%0A%2B11234567890%0A++++1-8002353551%0A++++123-456-7890+++-Hello%21%0A%2B1+-+1234567890+%0A'
          3        DO_ICALL                                         $2      
          4        ASSIGN                                                   !0, $2
   16     5      > FE_RESET_R                                       $4      !0, ->15
          6    > > FE_FETCH_R                                               $4, !1, ->15
   18     7    >   INIT_FCALL                                               'preg_replace'
          8        SEND_VAL                                                 '%7E.%2A%28%5Cd%7B3%7D%29%5B%5E%5Cd%5D%2A%28%5Cd%7B3%7D%29%5B%5E%5Cd%5D%2A%28%5Cd%7B4%7D%29.%2A%7E'
          9        SEND_VAL                                                 '%28%241%29+%242-%243'
         10        SEND_VAR                                                 !1
         11        DO_ICALL                                         $5      
         12        CONCAT                                           ~6      $5, '%0A'
         13        ECHO                                                     ~6
   16    14      > JMP                                                      ->6
         15    >   FE_FREE                                                  $4
   19    16      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
151.33 ms | 1395 KiB | 17 Q