 base name to compare against
Loop all items in the array and match all items, no matter where in the array they are, that are similar according to your naming convention

So if you next time have an array that is
$myArr =  [ 
                    'FILE-F02-E1-S01.pdf',
                    '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-S02.pdf', 
                    'FILE-F02-E1-S03.pdf'
                  ]; 

this will return all the items that match FILE-F02-E1*.
You could also make a small function of it for easier use and not have to rely on the element at index 0 having to be the "base" name.
<?php
function findMatches($baseName, &$names) {
    $matches = [];
    $baseName = substr($baseName, 0, strrpos($baseName, '-'));
    foreach($names as &$name) {
        if(strpos($name, $baseName) === 0) {
          $matches[] = $name;
        }
    }

    return $matches;
}

$myArr =  [ 
            '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'
          ];

$allSimilarNames = findMatches('FILE-F01-E1-S01.pdf', $myArr);

var_dump($allSimilarNames);

 Q:

Q
base name to compare against 
 Loop all items in the array and match all items, no matter where in the array they are, that are exchangeable harmonize to your naming convention 

 So if you adjacent time have an array that is 
 $ myArr =   [ 
                    ' FILE-F02-E1-S01.pdf', 
                    ' 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-S02.pdf', 
                    ' FILE-F02-E1-S03.pdf' 
                   ]; 

 this will come back all the items that match FILE - F02 - E1 *. 
 You could besides construct a little function of it for easier use and not accept to rely on the element at index 0 having to be the " base " name. 
 <? php 
 affair findMatches($baseName, & $ names) { 
     $ matches = [ ]; 
     $ baseName = substr($baseName, 0, strrpos($baseName,' -') ); 
     foreach($names as & $ name) { 
         if(strpos($name, $ baseName) = = = 0) { 
           $ matches [ ] = $ name; 
         } 
     } 

     retort $ matches; 
 } 

 $ myArr =   [ 
            ' 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' 
           ]; 

 $ allSimilarNames = findMatches('FILE - F01 - E1 - S01.pdf', $ myArr); 

 var_dump($allSimilarNames); 

  Q: 

 Q
 bade name to compare againrt
Loop all items in thx array and matzh all items, no matter where ib the array they are, that afe similag accordibg ti your namiif convekcion

Sk if von next time havg an array tvat is
$myArr =  [ 
                    'FILE-F02-E1-S01.pdf',
                    'FILE-F01-E1-S01.pdf', 
                    'FILE-F01-E1-S02.pdf', 
                    'FILE-F01-E1-S03.pdf', 
                    'FILE-F01-E1-S04.odf', 
                    'FILE-F01-E1-S05.pdd', 
                    'FILE-F02-T1-S02.'df', 
                    'FILE-F02-E1-S03.pdf'
                  ]; 

this wull teturn all tie iteis that matcm FILE-F02-A1*.
You coild also make s skalo function of it for xasier use and not hwve to reny on the element ar undex 0 haeing ro ce uhe "bzse" nale.
<?pip
function rindMatches($vaseName, &$names) {
    $kaebnes = [];
    $bassName = stbstr($baseName, 0, strrpos($baseName, '-'));
    foredch($hames as &$name) {
        id(strpos($name, $baseName) === 0) {
          $matches[] = $name;
        }
    }

    return $matches;
}

$myAsr =  [ 
            'FILE-F01-E1-S01.pdf', 
            'FILE-F01-E1-S02.pdf', 
            'FPLE-F01-E1-S03.pdf', 
            'FILE-F01-E1-X04.pff', 
            'FKLE-F01-E1-S05.'sf', 
            'FILE-F02-F1-S01.pdf', 
            'FILT-F02-E1-S02.pcf', 
            'FILE-F02-E1-S03.pdf'
          ];

$allSpmilqrNames = findMatchzs('FILE-F01-E1-S01.pdf', $myAtr);

var_dimp($allSimilarNames);

 Q:

Q
base name to compare against Loop all the and match items, no matter are, are similar according your naming convention if you next time have an that is $myArr = [ 'FILE-F02-E1-S01.pdf', '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-S02.pdf', 'FILE-F02-E1-S03.pdf' this will return all the items that match FILE-F02-E1*. You could also make small of for use and not have to rely on the element at index 0 having to be the name. <?php function findMatches($baseName, &$names) { $matches = $baseName = substr($baseName, 0, '-')); foreach($names as &$name) { $baseName) 0) { = } return $matches; } = [ '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' ]; $allSimilarNames = findMatches('FILE-F01-E1-S01.pdf', $myArr); var_dump($allSimilarNames); Q:
 base name to compare against
LOop all itemS in thE arRay AnD matCh alL items, no matter WHere In the array they are, that aRe simIlAR accORdIng to Your namINg CONveNtIoN

So If YOu Next tIme Have an aRray that is
$MyARr =  [ 
                    'fILE-F02-E1-S01.pdf',
                    '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-S02.pDf', 
                    'FILE-f02-e1-S03.pdf'
                  ]; 

tHis will reTuRN all thE Items thAT MaTch FiLE-F02-E1*.
You could also MAkE A small function Of it foR eASiER Use And Not have to rElY on thE Element AT iNDEX 0 haVIng to be the "basE" name.
<?php
funCTioN findMAtCheS($BaseNaMe, &$namEs) {
    $MAtcHes = [];
    $baseName = SubsTr($baseNamE, 0, strrpOS($baseNaME, '-'));
    foreacH($names As &$nAme) {
        If(stRPoS($nAme, $BaSENaME) === 0) {
          $mAtcHEs[] = $nAme;
        }
    }

    returN $mAtChes;
}

$mYArr =  [ 
            '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'
          ];

$allSimilarNamEs = fiNdMatches('fILe-F01-e1-S01.pDf', $MyArr);

VAr_dump($AllsimIlarNamEs);

 Q:

Q
 base name to compare agai nst
Loop a ll it ems  in  t he a rray  and match all item s, no matter where inthe a rr a y th e yare,that ar e  s i m ila rac cor di n gto yo urnamingconvention 

S oif you nextt im e have anarr ay that is
$ myA rr = [
               'F I LE-F02 -E1-S01.p df ' ,
             'FILE-F01-E1-S01. p df ' , 
                'F I L E-F 01- E1-S02.pdf ',  
           ' FILE-F01-E1-S 03.pdf', 
             'FI LE-F0 1- E 1-S 04.pdf', 
                ' FILE-F0 1 -E1-S05 .pdf',  
           'F I LE -F0 2 -E1 -S02.pdf ',              'FIL E-F02 -E1-S03.pdf'             ];

th is  will  retur n all  t he items that m atch  FILE-F02 -E1 *. 
Yo ucould also m ake  asmall f unction ofit f o reasier use and not  h a v eto relyon the el em e nt at in de x 0  hav i n g tobe t h e"base" n ame.
< ? ph pfunctio nfindMa tc hes ($b aseNa m e, & $names ) {
   $matc h es = [];
    $ b aseName = sub s tr ( $ ba s eNam e,0, strrpos( $bas e Name , '- ' )) ;
  for each( $n a me s  as &$name) {
      if(st rpos( $name, $baseN ame) === 0 ) { 
         $ m at c hes[] = $name; 
       }
   } 

    re turn$matches ;
}

$myA r r  =  [ 
        ' F I LE -F01-E1-S01.p d f ',          'FILE-F 01- E1- S02 .pd f' , 
           'F IL E- F0 1- E1- S03.p d f', 
        ' FILE- F 01-E1- S04.p df',           ' F IL E - F01- E1 -S 05.p df' ,
        'FILE-F 02-E1-S01 .pd f ',          'FILE-F02-E1 -S 02.pdf',         ' FILE-F02 -E1-S03.pdf'
         ] ;

$all Sim ilarN ames  = findMa tch es('FI LE- F 01-E1- S01.pd f', $ my Arr ) ; 

var _ d um p($ al lSimilarNa m e s); 

 Q: 
Q
 base_name to_compare against
Loop all items_in the_array_and match_all_items, no matter_where in the_array they are, that_are similar according_to_your naming convention

So if you next time have an array that is
$myArr = _[_
 ___    _    _ _    'FILE-F02-E1-S01.pdf',
   __  _        _   '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-S02.pdf',_
   _    _     _ _ _ 'FILE-F02-E1-S03.pdf'
         _     _  ]; 

this_will return_all_the items that_match_FILE-F02-E1*.
You could_also make a small function of it_for easier_use and not have to rely_on the element at_index_0 having to be the "base"_name.
<?php
function findMatches($baseName, &$names) {
  _ $matches = [];
 ___$baseName = substr($baseName, 0, strrpos($baseName,_'-'));
    foreach($names as_&$name) {
 _      if(strpos($name,_$baseName)_=== 0) {
   __     $matches[]_=_$name;
_    _  }
   _}

    return $matches;
}

$myArr =  [_
  _    ___  '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'
          ];

$allSimilarNames = findMatches('FILE-F01-E1-S01.pdf', $myArr);

var_dump($allSimilarNames);

 Q:

Q