3v4l.org

run code in 300+ PHP versions simultaneously
<?php $arr = array ( 0 => 'FOLDER./Images.Vacation.2018', 1 => './Images.Vacation.2018/Racoon001.jpg', 2 => './Images.Vacation.2018/Racoon002.txt', 3 => './Images.Vacation.2018/the.racoon.swimming.mp4', 4 => './Images.Vacation.2018/the.racoon.swimming.slv', 5 => 'FOLDER./WestImages', 6 => './WestImages/Ramco.txt', 7 => './WestImages/Ramco.jpg', 8 => 'FOLDER./WestImages/Subimages', 9 => './WestImages/Subimages/Image001.jpg', 10 => './WestImages/Subimages/Image002.jpg', 11 => './WestImages/West.Ramco.Swimming.mp4', ); $folders = preg_grep("/^FOLDER.*/", $arr); foreach($folders as $folder){ $result[] = $folder; $result = array_merge($result, preg_grep("/^\." . str_replace(["FOLDER.", "/"], ["","\/"], $folder) . "\/[A-Za-z0-9\.]+$/", $arr)); } var_dump($result);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 7, Position 2 = 27
Branch analysis from position: 7
2 jumps found. (Code = 78) Position 1 = 8, Position 2 = 27
Branch analysis from position: 8
1 jumps found. (Code = 42) Position 1 = 7
Branch analysis from position: 7
Branch analysis from position: 27
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 27
filename:       /in/BthA0
function name:  (null)
number of ops:  32
compiled vars:  !0 = $arr, !1 = $folders, !2 = $folder, !3 = $result
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   18     1        INIT_FCALL                                               'preg_grep'
          2        SEND_VAL                                                 '%2F%5EFOLDER.%2A%2F'
          3        SEND_VAR                                                 !0
          4        DO_ICALL                                         $5      
          5        ASSIGN                                                   !1, $5
   20     6      > FE_RESET_R                                       $7      !1, ->27
          7    > > FE_FETCH_R                                               $7, !2, ->27
   21     8    >   ASSIGN_DIM                                               !3
          9        OP_DATA                                                  !2
   22    10        INIT_FCALL                                               'array_merge'
         11        SEND_VAR                                                 !3
         12        INIT_FCALL                                               'preg_grep'
         13        INIT_FCALL                                               'str_replace'
         14        SEND_VAL                                                 <array>
         15        SEND_VAL                                                 <array>
         16        SEND_VAR                                                 !2
         17        DO_ICALL                                         $9      
         18        CONCAT                                           ~10     '%2F%5E%5C.', $9
         19        CONCAT                                           ~11     ~10, '%5C%2F%5BA-Za-z0-9%5C.%5D%2B%24%2F'
         20        SEND_VAL                                                 ~11
         21        SEND_VAR                                                 !0
         22        DO_ICALL                                         $12     
         23        SEND_VAR                                                 $12
         24        DO_ICALL                                         $13     
         25        ASSIGN                                                   !3, $13
   20    26      > JMP                                                      ->7
         27    >   FE_FREE                                                  $7
   25    28        INIT_FCALL                                               'var_dump'
         29        SEND_VAR                                                 !3
         30        DO_ICALL                                                 
         31      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
140.97 ms | 1441 KiB | 17 Q