Is there any way that php can find all the mp3 files in a directory(even inside sub directories)? So you don't have to find them manually and you can add music easier?
您可以尝试使用glob()
函数:
print_r(glob("*.mp3"));
This will give you all files including sub-directories.
$Regex will have single index array of all files you need.
<?php
$Directory = new RecursiveDirectoryIterator('path/to/project/');
$Iterator = new RecursiveIteratorIterator($Directory);
$Regex = new RegexIterator($Iterator, '/^.+\.mp3$/i', RecursiveRegexIterator::GET_MATCH);
?>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.