Reputation: 5345
I am using PHP 7.4.1
.
I am trying to get files from a certain folder and I use the following code for this:
array_diff(scandir($views . "/Text"), array('.', '..'));
I have the following folder structure:
Texts/
├── test1.blade.php
└── Parts
test1.blade.php
is a file and Parts
is a folder.
The above code gives me back files AND folders.
I would only like to get all .blade.php
files in my array.
Any suggestions how to filter out the folder(s)?
Appreciate your replies!
Upvotes: 0
Views: 337
Reputation: 409
$result = array_filter($result, 'is_file');
- files$result = array_filter($result, 'is_dir');
- foldersUpvotes: 3