3v4l.org

run code in 300+ PHP versions simultaneously
<?php $strings = ['12345', 'L12345', 'L1S1', 'LS1', 'L123S45', 'L1x23S4yZY5', 'L1x!23S4y5']; foreach($strings as $string) { $hasMatches = preg_match_all('/^L([0-9a-zA-Z]+)S([0-9a-zA-Z]+)/m', $string, $matches, PREG_SET_ORDER, 0); if(filter_var($hasMatches, FILTER_VALIDATE_BOOLEAN)) { // converts $hasMatches to boolean echo 'THERE IS A MATCH: "' . $matches[0][0] . '"' . "\n"; echo '1st part: ' . $matches[0][1] . "\n"; echo '2nd part: ' . $matches[0][2] . "\n\n"; } }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 2, Position 2 = 33
Branch analysis from position: 2
2 jumps found. (Code = 78) Position 1 = 3, Position 2 = 33
Branch analysis from position: 3
2 jumps found. (Code = 43) Position 1 = 16, Position 2 = 32
Branch analysis from position: 16
1 jumps found. (Code = 42) Position 1 = 2
Branch analysis from position: 2
Branch analysis from position: 32
Branch analysis from position: 33
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 33
filename:       /in/nRnEd
function name:  (null)
number of ops:  35
compiled vars:  !0 = $strings, !1 = $string, !2 = $hasMatches, !3 = $matches
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
    5     1      > FE_RESET_R                                       $5      !0, ->33
          2    > > FE_FETCH_R                                               $5, !1, ->33
    6     3    >   INIT_FCALL                                               'preg_match_all'
          4        SEND_VAL                                                 '%2F%5EL%28%5B0-9a-zA-Z%5D%2B%29S%28%5B0-9a-zA-Z%5D%2B%29%2Fm'
          5        SEND_VAR                                                 !1
          6        SEND_REF                                                 !3
          7        SEND_VAL                                                 2
          8        SEND_VAL                                                 0
          9        DO_ICALL                                         $6      
         10        ASSIGN                                                   !2, $6
    7    11        INIT_FCALL                                               'filter_var'
         12        SEND_VAR                                                 !2
         13        SEND_VAL                                                 258
         14        DO_ICALL                                         $8      
         15      > JMPZ                                                     $8, ->32
    8    16    >   FETCH_DIM_R                                      ~9      !3, 0
         17        FETCH_DIM_R                                      ~10     ~9, 0
         18        CONCAT                                           ~11     'THERE+IS+A+MATCH%3A+%22', ~10
         19        CONCAT                                           ~12     ~11, '%22'
         20        CONCAT                                           ~13     ~12, '%0A'
         21        ECHO                                                     ~13
    9    22        FETCH_DIM_R                                      ~14     !3, 0
         23        FETCH_DIM_R                                      ~15     ~14, 1
         24        CONCAT                                           ~16     '1st+part%3A+', ~15
         25        CONCAT                                           ~17     ~16, '%0A'
         26        ECHO                                                     ~17
   10    27        FETCH_DIM_R                                      ~18     !3, 0
         28        FETCH_DIM_R                                      ~19     ~18, 2
         29        CONCAT                                           ~20     '2nd+part%3A+', ~19
         30        CONCAT                                           ~21     ~20, '%0A%0A'
         31        ECHO                                                     ~21
    5    32    > > JMP                                                      ->2
         33    >   FE_FREE                                                  $5
   12    34      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
137.71 ms | 1002 KiB | 15 Q