我正在尝试使用PHP将文件夹中的多个文件分组到播放列表中。所以,我正在使用这段代码来查找和分组具有不同格式的视频文件到一个名称,但它不起作用。
$path = realpath(dirname(__FILE__)) . "/vidd";
echo $path;
$dir_handle = @opendir($path);
while (FALSE != ($file2 = readdir($dir_handle))) {
if ($file2 != '.' && $file2 != '..') {
if (strstr($file2, ".mp4") || strstr($file2, ".webm") || strstr($file2, ".flv") || strstr($file2, ".3gp")) {
$fileNamepart = explode(".", $file2);
while (FALSE != ($file3 = readdir($dir_handle))) {
if ($file3 != '.' && $file3 != '..') {
if (strstr($file3, ".mp4") || strstr($file3, ".webm") || strstr($file3, ".flv") || strstr($file3, ".3gp")) {
$fileNamepart1 = explode(".", $file3);
if (stristr($fileNamepart[0], $fileNamepart1[0])) {
echo $file3;
}
}
}
}
}
}
}
在Vidd目录中存在这些文件。
▶孤岛危机3 - CryEngine3技术预告片 - YouTube [480p] .flv
▶孤岛危机3 - CryEngine3技术预告片 - YouTube [240p] .flv
▶孤岛危机3 - CryEngine3技术预告片 - YouTube [144p] .3gp
▶孤岛危机3 - CryEngine3技术预告片 - YouTube [720p] .mp4
▶孤岛危机3 - CryEngine3技术预告片 - YouTube [360p] .webm
▶孤岛危机3 - CryEngine3技术预告片 - YouTube [360p] .flv
▶孤岛危机3 - CryEngine3技术预告片 - YouTube [720p] .webm
▶孤岛危机3 - CryEngine3技术预告片 - YouTube [360p] .mp4
▶孤岛危机3 - CryEngine3技术预告片 - YouTube [240p] .3gp
▶孤岛危机3 - CryEngine3技术预告片 - YouTube [480p] .webm
my_video.mp4
turisas_interview.flv
my_video.mp4
如何将这些文件分组到播放列表中,该播放列表仅显示文件名而不显示特定格式。所以从上面的文件列表中,程序应该生成:
▶孤岛危机3 - CryEngine3 Tech Trailer
my_video.mp4
turisas_interview.flv
my_video.mp4。
然后我会从中列出ul
列表。然后将原始文件提供给Video.js
以便在浏览器上查看。
任何人都可以帮我解决这个问题,我正在努力,但找不到一个简单的方法来做到这一点。