Php glob quét tìm file
Bạn cần hàm này để tìm định file cần tìm. 2 Hàm là như nhau nhé, có thể chọn cái nào tùy thích của bạn
private function glob_recursive($pattern, $flags = 0)
{
$files = glob($pattern, $flags);
foreach (glob(dirname($pattern).'/*', GLOB_ONLYDIR|GLOB_NOSORT) as $dir)
{
$files = array_merge($files, $this->glob_recursive($dir.'/'.basename($pattern), $flags));
}
return $files;
}
public function rglob($pattern, $flags = 0) {
$files = glob($pattern, $flags);
foreach (glob(dirname($pattern).'/*', GLOB_ONLYDIR|GLOB_NOSORT) as $dir) {
$files = array_merge($files, $this->rglob($dir.'/'.basename($pattern), $flags));
}
return $files;
}
Tin tức khác
- Laravel updateOrCreate lấy trạng thái insert or update
- Lazy load cho Google tag manager tăng tốc trên PageSpeed
- Wordpress 5 phân trang - wordpress 5 pagination
- PHP So sánh thời gian hơn 24h
- PHP convert multidimensional array to one array using function Flatten
- PHP multidimensional array search by key value array
- Php export data to excel 2007 xlsx
© Copyright 2023. Thiết kế website bởi Fdola.com