its a mystery to me why this is happening. so here is the code:
$dir = 'test/';
$de = opendir($dir);
if ($de) {
while (($file = readdir($de)) !== false) {
$path = $dir . $file;
$file_title = 'this text gets repeated three times, each followed by a dot' . $file;
echo $file;
}
} else {
echo "invalid directory";
}
so If $file= video.mp4 and $file_title='file name'.$file; it would look like this:
'file name.file name.file namevideo.mp4' and if there were no string before the variable, ie $file_title=$title there would be three dots before the variable like this: ...video.mp4
if anyone has any idea what's happening please let me know. Thanks.
You get repeating text because your code contains a loop. That's what while
does: it runs code repeatedly.
You are listing the .
and ..
directories, use is_file()
to check so the entry is really a file and not a directory:
if (is_file($dir . $file)) {
// entry is a file
}
Here you can read more about the dot
directories: There's a lot in the dot
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.