3v4l.org

run code in 300+ PHP versions simultaneously
<?php function matchStrings($str) { $ret = array(); // $ret = explode("\n", $str); foreach($ret as $asub) { $asub = str_replace('x', '', $asub); preg_match('/^(sh[0-9]+sh)+/', trim($asub), $ret['matches'][]); } $ret = array_unique($ret['matches']); foreach($ret as $sfind) { var_dump($sfind); } return $ret; // } $test = <<<MULTI xx xx sh1sh xx xx xx sh2sh xx xx xx xx sh**sh xx xx x xx xx sh3xxxsh xx xx sh4shsh5sh xxx MULTI; $matches = matchStrings($test); print_r($matches);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/UMbhs
function name:  (null)
number of ops:  9
compiled vars:  !0 = $test, !1 = $matches
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   23     0  E >   ASSIGN                                                   !0, '++++xx+xx+sh1sh+xx+xx%0A++++xx+sh2sh+xx+xx+xx%0A++++xx+sh%2A%2Ash+xx+xx+x%0A++++xx+xx+sh3xxxsh+xx%0A++++xx+sh4shsh5sh+xxx'
   31     1        INIT_FCALL                                               'matchstrings'
          2        SEND_VAR                                                 !0
          3        DO_FCALL                                      0  $3      
          4        ASSIGN                                                   !1, $3
   33     5        INIT_FCALL                                               'print_r'
          6        SEND_VAR                                                 !1
          7        DO_ICALL                                                 
          8      > RETURN                                                   1

Function matchstrings:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 8, Position 2 = 26
Branch analysis from position: 8
2 jumps found. (Code = 78) Position 1 = 9, Position 2 = 26
Branch analysis from position: 9
1 jumps found. (Code = 42) Position 1 = 8
Branch analysis from position: 8
Branch analysis from position: 26
2 jumps found. (Code = 77) Position 1 = 33, Position 2 = 38
Branch analysis from position: 33
2 jumps found. (Code = 78) Position 1 = 34, Position 2 = 38
Branch analysis from position: 34
1 jumps found. (Code = 42) Position 1 = 33
Branch analysis from position: 33
Branch analysis from position: 38
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 38
Branch analysis from position: 26
filename:       /in/UMbhs
function name:  matchStrings
number of ops:  41
compiled vars:  !0 = $str, !1 = $ret, !2 = $asub, !3 = $sfind
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
    4     1        ASSIGN                                                   !1, <array>
    6     2        INIT_FCALL                                               'explode'
          3        SEND_VAL                                                 '%0A'
          4        SEND_VAR                                                 !0
          5        DO_ICALL                                         $5      
          6        ASSIGN                                                   !1, $5
    8     7      > FE_RESET_R                                       $7      !1, ->26
          8    > > FE_FETCH_R                                               $7, !2, ->26
    9     9    >   INIT_FCALL                                               'str_replace'
         10        SEND_VAL                                                 'x'
         11        SEND_VAL                                                 ''
         12        SEND_VAR                                                 !2
         13        DO_ICALL                                         $8      
         14        ASSIGN                                                   !2, $8
   10    15        INIT_FCALL                                               'preg_match'
         16        SEND_VAL                                                 '%2F%5E%28sh%5B0-9%5D%2Bsh%29%2B%2F'
         17        INIT_FCALL                                               'trim'
         18        SEND_VAR                                                 !2
         19        DO_ICALL                                         $10     
         20        SEND_VAR                                                 $10
         21        FETCH_DIM_W                                      $11     !1, 'matches'
         22        FETCH_DIM_W                                      $12     $11
         23        SEND_REF                                                 $12
         24        DO_ICALL                                                 
    8    25      > JMP                                                      ->8
         26    >   FE_FREE                                                  $7
   13    27        INIT_FCALL                                               'array_unique'
         28        FETCH_DIM_R                                      ~14     !1, 'matches'
         29        SEND_VAL                                                 ~14
         30        DO_ICALL                                         $15     
         31        ASSIGN                                                   !1, $15
   15    32      > FE_RESET_R                                       $17     !1, ->38
         33    > > FE_FETCH_R                                               $17, !3, ->38
   16    34    >   INIT_FCALL                                               'var_dump'
         35        SEND_VAR                                                 !3
         36        DO_ICALL                                                 
   15    37      > JMP                                                      ->33
         38    >   FE_FREE                                                  $17
   19    39      > RETURN                                                   !1
   21    40*     > RETURN                                                   null

End of function matchstrings

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
168.24 ms | 1402 KiB | 28 Q