我想在一个文件夹中获取一些视频文件,假设.mp4,.mp3,.flv..etc扩展名并排除.webm扩展名等文件。如何用php condeigniter执行此操作?
答案 0 :(得分:0)
编写像这样的自定义函数
function getCount(){
$overAllCount = 0;
$directory = base_url().'uploads';
$mp4count = glob($directory . '*.mp4');
$mp3count = glob($directory . '*.mp3');
$flvcount = glob($directory . '*.flv');
if ( $mp4count !== false )
{
$filecount = count( $mp4count );
$overAllCount += $filecount;
}
if ( $flvcount !== false )
{
$filecount = count( $flvcount );
$overAllCount += $filecount;
}
if ( $mp3count!== false )
{
$filecount = count( $mp3count);
$overAllCount += $filecount;
}
return $overAllCount;
}