Currently I have these files in a folder:
Is it possible to make list all files that start with server_log and display those filenames on the screen?
Currently I have these files in a folder:
Is it possible to make list all files that start with server_log and display those filenames on the screen?
Use glob()
. The glob() function searches for all the pathnames matching pattern according to the rules used by the libc glob() function, which is similar to the rules used by common shells.
$ListFile = glob("/path/server_log_*");
print_r($ListFile);
Yes, take a look at this answer.
$dir ="your path here";
$filetoread ="server_log";
if (is_dir($dir)) {
if ($dh = opendir($dir)) {
while (($file = readdir($dh)) !== false) {
if (strpos($file,$filetoread) !== false)
echo "filename: $file : filetype: " . filetype($dir . $file) . "\n";
}
closedir($dh);
}
}