3v4l.org

run code in 500+ PHP versions simultaneously
<?php $array = [ 'FILE-F01-E1-S01.pdf', 'FILE-F01-E1-S02.pdf', 'FILE-F01-E1-S03.pdf', 'FILE-F01-E1-S04.pdf', 'FILE-F01-E1-S05.pdf', 'FILE-F02-E1-S01.pdf', 'FILE-F02-E1-S02.pdf', 'FILE-F02-E1-S03.pdf', "TESTFILE-F01-E1-S03.pdf" ]; $parts = explode('-', $array[0]); array_pop($parts); $fileBeginning = implode('-', $parts); $secondArray = array_filter($array, function ($x) use ($fileBeginning) { return substr($x, 0, strlen($fileBeginning)) === $fileBeginning; }); print_r($secondArray);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/6glNU
function name:  (null)
number of ops:  23
compiled vars:  !0 = $array, !1 = $parts, !2 = $fileBeginning, !3 = $secondArray
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                       !0, <array>
   14     1        INIT_FCALL                                                   'explode'
          2        SEND_VAL                                                     '-'
          3        FETCH_DIM_R                                          ~5      !0, 0
          4        SEND_VAL                                                     ~5
          5        DO_ICALL                                             $6      
          6        ASSIGN                                                       !1, $6
   15     7        INIT_FCALL                                                   'array_pop'
          8        SEND_REF                                                     !1
          9        DO_ICALL                                                     
   16    10        FRAMELESS_ICALL_2                implode             ~9      '-', !1
         11        ASSIGN                                                       !2, ~9
   17    12        INIT_FCALL                                                   'array_filter'
         13        SEND_VAR                                                     !0
         14        DECLARE_LAMBDA_FUNCTION                              ~11     [0]
         15        BIND_LEXICAL                                                 ~11, !2
   19    16        SEND_VAL                                                     ~11
   17    17        DO_ICALL                                             $12     
         18        ASSIGN                                                       !3, $12
   20    19        INIT_FCALL                                                   'print_r'
         20        SEND_VAR                                                     !3
         21        DO_ICALL                                                     
         22      > RETURN                                                       1


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/6glNU
function name:  {closure:/in/6glNU:17}
number of ops:  8
compiled vars:  !0 = $x, !1 = $fileBeginning
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   17     0  E >   RECV                                                 !0      
          1        BIND_STATIC                                                  !1
   18     2        STRLEN                                               ~2      !1
          3        FRAMELESS_ICALL_3                substr              ~3      !0, 0
          4        OP_DATA                                                      ~2
          5        IS_IDENTICAL                                         ~4      !1, ~3
          6      > RETURN                                                       ~4
   19     7*     > RETURN                                                       null

End of Dynamic Function 0

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
166.69 ms | 2567 KiB | 17 Q