3v4l.org

run code in 300+ PHP versions simultaneously
<?php $input = [ 'new message from Bob [22:105:3905:534]', 'user Dylan posted a question in section General', 'new message from Mary(gold) [19504:8728:18524:78941]' ]; $formats = [ '/new message from (\w+) \[(\d+):(\d+):(\d+):(\d+)\]/', // this would actually be something like '/(?<=new message from )(.*)(?=[)(.*)(?=:)(.*)(?=:)(.*)(?=:)(.*)(?=])/' '/user (\w+) posted a question in section ([\w ]+)/', '/new message from (\w+)\((\w+)\) \[(\d+):(\d+):(\d+):(\d+)\]/', ]; foreach ($input as $line) { foreach ($formats as $key => $format) { $data = []; if (preg_match($format, $line, $data)) { array_shift($data); echo 'format: ' . $key . ', data: ' . var_export($data, true) . "\n"; continue; } } }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 30
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 30
Branch analysis from position: 4
2 jumps found. (Code = 77) Position 1 = 5, Position 2 = 28
Branch analysis from position: 5
2 jumps found. (Code = 78) Position 1 = 6, Position 2 = 28
Branch analysis from position: 6
2 jumps found. (Code = 43) Position 1 = 14, Position 2 = 27
Branch analysis from position: 14
1 jumps found. (Code = 42) Position 1 = 5
Branch analysis from position: 5
Branch analysis from position: 27
1 jumps found. (Code = 42) Position 1 = 5
Branch analysis from position: 5
Branch analysis from position: 28
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 28
Branch analysis from position: 30
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 30
filename:       /in/NBgaT
function name:  (null)
number of ops:  32
compiled vars:  !0 = $input, !1 = $formats, !2 = $line, !3 = $format, !4 = $key, !5 = $data
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
    9     1        ASSIGN                                                   !1, <array>
   15     2      > FE_RESET_R                                       $8      !0, ->30
          3    > > FE_FETCH_R                                               $8, !2, ->30
   16     4    > > FE_RESET_R                                       $9      !1, ->28
          5    > > FE_FETCH_R                                       ~10     $9, !3, ->28
          6    >   ASSIGN                                                   !4, ~10
   17     7        ASSIGN                                                   !5, <array>
   18     8        INIT_FCALL                                               'preg_match'
          9        SEND_VAR                                                 !3
         10        SEND_VAR                                                 !2
         11        SEND_REF                                                 !5
         12        DO_ICALL                                         $13     
         13      > JMPZ                                                     $13, ->27
   19    14    >   INIT_FCALL                                               'array_shift'
         15        SEND_REF                                                 !5
         16        DO_ICALL                                                 
   20    17        CONCAT                                           ~15     'format%3A+', !4
         18        CONCAT                                           ~16     ~15, '%2C+data%3A+'
         19        INIT_FCALL                                               'var_export'
         20        SEND_VAR                                                 !5
         21        SEND_VAL                                                 <true>
         22        DO_ICALL                                         $17     
         23        CONCAT                                           ~18     ~16, $17
         24        CONCAT                                           ~19     ~18, '%0A'
         25        ECHO                                                     ~19
   21    26      > JMP                                                      ->5
   16    27    > > JMP                                                      ->5
         28    >   FE_FREE                                                  $9
   15    29      > JMP                                                      ->3
         30    >   FE_FREE                                                  $8
   24    31      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
144.54 ms | 1401 KiB | 19 Q