Hi,
I would like to list all the items contained in a folder except for 2 or 3 specific ones.
For example, let's say I've item 1, item 2, …, item 10 in /myFolder. I would like to list all the items of /myFolder but item 1, item 3 and item 4. I've come up with the following code which does the work but looks a bit awkward.
<?php
$dir = '/myFolder';
$filesDir = new FilesystemIterator($dir, FilesystemIterator::SKIP_DOTS);
$fileName = '';
foreach ($filesDir as $file) {
$fileName = $file->getBasename();
if ($fileName != 'item1' && $fileName != 'item3' && $fileName != 'item4') {
echo $fileName.'<br>';
}
}
Is there a simple and more elegant way to accomplish this?
Any help would be appreciated, thanks!