i want to know how to check the filename in folder with some condition.
for example : the folder name is "output" this folder containing the following the images. 2323a.Png 5235v.Jpeg 2323s.jpg 23523s.JPEG etc..,
if i check the file name is "2323a.png" but there is file name is 2323a.Png.
how to i check the filename is incasesensitive.
thanks in advance
Imho you have to read the directory contents
function file_exists_ignore_case($path) {
$dirname = dirname($path);
$filename = basename($path);
$dir = dir($dirname);
while (($file = $dir->read()) !== false) {
if (strtolower($file) == strtolower($filename)) {
$dir->close();
return true;
}
}
$dir->close();
return false;
}
在文件名上使用strtolower来检查它们是否存在。
if(strtolower($filename) === '2323a.png')
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.