Created
December 16, 2015 20:17
-
-
Save hmschreiner/0e0a6c7c4c7256c7ecb1 to your computer and use it in GitHub Desktop.
Recursive Directory Iteration for MP3 files
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$path = realpath('/home/user/Music'); | |
$ite = new RecursiveDirectoryIterator($path); | |
$files = array(); | |
foreach (new RecursiveIteratorIterator($ite) as $filename => $cur) { | |
if($cur->isDir() || $cur->getExtension() != 'mp3') { | |
continue; | |
} | |
$files[] = array( | |
'name' => $cur->getFileName(), | |
'path' => $filename, | |
'extension' => $cur->getExtension(), | |
); | |
} | |
echo '<pre>'; | |
print_r($files); | |
echo '</pre>'; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment