我有一個腳本和一個函數在其中獲取該文件夾中的每個文件。如何編輯此代碼以使其僅獲取.png文件?PhP搜索目錄通過文件擴展名
public function GetPreviews($category)
{
$directories = glob("assets/preview/$category/*");
$directory = array();
foreach($directories as $directories)
{
$directory[] = str_replace("assets/preview/$category/", "", $directories);
}
return $directory;
}
你看了手冊http://php.net/manual/en/function.glob.php – 2014-11-21 14:34:54