3v4l.org

run code in 300+ PHP versions simultaneously
<?php $filesets[] = 'Include { Options { signature = MD5 } file = /backup } Exclude { file = /backup/elasticsearch }'; $filesets[] = 'Include { Options { wildfile = "/backup/*/" } Options { ...another set of options... } file = /backup }'; $filesets[] = 'Include { file = /backup/a } Include { file = /backup/b }'; $filesets[] = 'Exclude { file = /backup/raw } Include { file = /backup }'; foreach ($filesets as $c) { var_dump(getFolders($c)); echo "\n\n"; } function getFolders($content) { $content = str_replace(array("\n", " "), array('', ''), $content); // remove options $content = preg_replace('/Options{+(.*?)}/i', '', $content); // match include files if (!preg_match_all('/Include{file=(.*?)}/i', $content, $matches)) { echo "NOPE"; } $folders = explode('file=', $matches[1]); array_shift($folders); return $folders; }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 9, Position 2 = 18
Branch analysis from position: 9
2 jumps found. (Code = 78) Position 1 = 10, Position 2 = 18
Branch analysis from position: 10
1 jumps found. (Code = 42) Position 1 = 9
Branch analysis from position: 9
Branch analysis from position: 18
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 18
filename:       /in/RmY9I
function name:  (null)
number of ops:  20
compiled vars:  !0 = $filesets, !1 = $c
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN_DIM                                               !0
          1        OP_DATA                                                  'Include+%7B%0A++Options+%7B%0A++++signature+%3D+MD5%0A++%7D%0A++file+%3D+%2Fbackup%0A%7D%0AExclude+%7B%0A++file+%3D+%2Fbackup%2Felasticsearch%0A%7D'
   12     2        ASSIGN_DIM                                               !0
          3        OP_DATA                                                  'Include+%7B%0A++++Options+%7B+wildfile+%3D+%22%2Fbackup%2F%2A%2F%22+%7D%0A++++Options+%7B+...another+set+of+options...+%7D%0A++++file+%3D+%2Fbackup%0A%7D'
   18     4        ASSIGN_DIM                                               !0
          5        OP_DATA                                                  'Include+%7B+file+%3D+%2Fbackup%2Fa+%7D+Include+%7B+file+%3D+%2Fbackup%2Fb+%7D'
   20     6        ASSIGN_DIM                                               !0
          7        OP_DATA                                                  'Exclude+%7B+file+%3D+%2Fbackup%2Fraw+%7D%0AInclude+%7B+file+%3D+%2Fbackup+%7D'
   23     8      > FE_RESET_R                                       $6      !0, ->18
          9    > > FE_FETCH_R                                               $6, !1, ->18
   24    10    >   INIT_FCALL                                               'var_dump'
         11        INIT_FCALL_BY_NAME                                       'getFolders'
         12        SEND_VAR_EX                                              !1
         13        DO_FCALL                                      0  $7      
         14        SEND_VAR                                                 $7
         15        DO_ICALL                                                 
   25    16        ECHO                                                     '%0A%0A'
   23    17      > JMP                                                      ->9
         18    >   FE_FREE                                                  $6
   43    19      > RETURN                                                   1

Function getfolders:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 20, Position 2 = 21
Branch analysis from position: 20
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 21
filename:       /in/RmY9I
function name:  getFolders
number of ops:  32
compiled vars:  !0 = $content, !1 = $matches, !2 = $folders
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   28     0  E >   RECV                                             !0      
   29     1        INIT_FCALL                                               'str_replace'
          2        SEND_VAL                                                 <array>
          3        SEND_VAL                                                 <array>
          4        SEND_VAR                                                 !0
          5        DO_ICALL                                         $3      
          6        ASSIGN                                                   !0, $3
   32     7        INIT_FCALL                                               'preg_replace'
          8        SEND_VAL                                                 '%2FOptions%7B%2B%28.%2A%3F%29%7D%2Fi'
          9        SEND_VAL                                                 ''
         10        SEND_VAR                                                 !0
         11        DO_ICALL                                         $5      
         12        ASSIGN                                                   !0, $5
   35    13        INIT_FCALL                                               'preg_match_all'
         14        SEND_VAL                                                 '%2FInclude%7Bfile%3D%28.%2A%3F%29%7D%2Fi'
         15        SEND_VAR                                                 !0
         16        SEND_REF                                                 !1
         17        DO_ICALL                                         $7      
         18        BOOL_NOT                                         ~8      $7
         19      > JMPZ                                                     ~8, ->21
   36    20    >   ECHO                                                     'NOPE'
   39    21    >   INIT_FCALL                                               'explode'
         22        SEND_VAL                                                 'file%3D'
         23        FETCH_DIM_R                                      ~9      !1, 1
         24        SEND_VAL                                                 ~9
         25        DO_ICALL                                         $10     
         26        ASSIGN                                                   !2, $10
   40    27        INIT_FCALL                                               'array_shift'
         28        SEND_REF                                                 !2
         29        DO_ICALL                                                 
   42    30      > RETURN                                                   !2
   43    31*     > RETURN                                                   null

End of function getfolders

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
161.03 ms | 1400 KiB | 25 Q