<?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);
- Output for 7.1.25 - 7.1.30, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.30, 8.2.0 - 8.2.25, 8.3.0 - 8.3.13
- array(12) {
[0]=>
string(28) "FOLDER./Images.Vacation.2018"
[1]=>
string(36) "./Images.Vacation.2018/Racoon001.jpg"
[2]=>
string(36) "./Images.Vacation.2018/Racoon002.txt"
[3]=>
string(46) "./Images.Vacation.2018/the.racoon.swimming.mp4"
[4]=>
string(46) "./Images.Vacation.2018/the.racoon.swimming.slv"
[5]=>
string(18) "FOLDER./WestImages"
[6]=>
string(22) "./WestImages/Ramco.txt"
[7]=>
string(22) "./WestImages/Ramco.jpg"
[8]=>
string(36) "./WestImages/West.Ramco.Swimming.mp4"
[9]=>
string(28) "FOLDER./WestImages/Subimages"
[10]=>
string(35) "./WestImages/Subimages/Image001.jpg"
[11]=>
string(35) "./WestImages/Subimages/Image002.jpg"
}
preferences:
61.09 ms | 409 KiB | 5 Q