在CFileHelper中通过其中文件名=某个名称查找文件


in CFileHelper findFiles by where file name = some name?

我只想从某个目录中找到那些文件,该目录等于数据库中数组的名称。简而言之,我有这个代码

$array = array(
    'img1.jpg','img2.jpg'
);
$array = serialize($array); 
$model->file=$array; 
$model->save();
// saved all the names in database and then:
$files = unserialize($model->file);
// and now, i have an array with the names:
Array
(
  [0] => img1.jpg
  [1] => img2.jpg
  [2] => img3.jpg
)
$path = 'files';
$data = CFileHelper::findFiles($path); // an array with files

在这里,我想做一些类似的事情;从$data或echo文件中查找$files,其中$data文件名=$files文件名

为什么不使用scandir()

$data = array('img1.gif','img2.gif'); // array of files from database
$files = scandir('/path/of/directory');
var_dump(array_intersect($data, $files));

读取sacndir()和array_entersect()