scandir

Where does “.” (dot) come from when using PHP ´scandir´

旧街凉风 提交于 2021-02-19 05:54:20
问题 I'm a bit confused. I'm building a PHP function to loop out images in a specified dir. PHP $dir = "bilder/".$objekt[0]['objekt_nr']."/thumbnail/"; $thumbnails = scandir($dir); print_r($thumbnails); foreach ($thumbnails as $value) { echo "<img src='".$dir.$value. "'>"; } array ( [0] => . [1] => .. [2] => bjornc.jpg [3] => test_bild3.jpg ) HTML <img src='bilder/22159/thumbnail/.'> <img src='bilder/22159/thumbnail/..'> <img src='bilder/22159/thumbnail/bjornc.jpg'> <img src='bilder/22159

Finding particular path in directory in Python

梦想与她 提交于 2020-12-29 08:09:37
问题 How could I find the path of the directory which contains a date like 20170423 ? meaning, it could be any date, but i want to have that specific path until i get a folder that contains a date.. There may be several sub-directories along the way that contain that pattern, but that's a special case, where i would need to give more precision, like the content of the folder to select the proper one. give it a shot if you d like for the special case, but for the case where i know that only one

How to get only video files from folder directory of all files in php?

北城余情 提交于 2020-08-07 09:45:56
问题 I have some videos,images and text files in "uploads/video/" dir. Here i am getting all the files using scandir but I want only videos from that folder. Sample code : $video_dir = 'uploads/video/'; $video_array = scandir($video_dir); unset($video_array[0]); unset($video_array[1]); echo "<pre>"; print_r($video_array); echo "</pre>"; Getting Result : Array ( [2] => ADD.mp4 [3] => COO_Notes.txt [4] => Carefree.mp3 [5] => Circus Tent.mp3 [6] => Phen.mp4 [7] => REM.mp4 [8] => images (9).jpg [9] =>

List all folders in directory (PHP) [duplicate]

若如初见. 提交于 2020-04-16 05:25:09
问题 This question already has answers here : PHP Get all subdirectories of a given directory (16 answers) Closed 2 years ago . How can I make my code only display links to the folders and not the files in the directory? $d = dir("."); echo "<ul>"; while(false !== ($entry = $d->read())) { echo "<li><a href='{$entry}'>{$entry}</a></li>"; } echo "</ul>"; $d->close(); 回答1: $d = dir("."); echo "<ul>"; while (false !== ($entry = $d->read())) { if (is_dir($entry) && ($entry != '.') && ($entry != '..'))

List all folders in directory (PHP) [duplicate]

半世苍凉 提交于 2020-04-16 05:24:29
问题 This question already has answers here : PHP Get all subdirectories of a given directory (16 answers) Closed 2 years ago . How can I make my code only display links to the folders and not the files in the directory? $d = dir("."); echo "<ul>"; while(false !== ($entry = $d->read())) { echo "<li><a href='{$entry}'>{$entry}</a></li>"; } echo "</ul>"; $d->close(); 回答1: $d = dir("."); echo "<ul>"; while (false !== ($entry = $d->read())) { if (is_dir($entry) && ($entry != '.') && ($entry != '..'))

How to set and use PHP_INI_SCAN_DIR environment variable in PHP? [duplicate]

走远了吗. 提交于 2020-01-13 05:47:08
问题 This question already has answers here : Is it mandatory to configure PHP in order to scan configuration INI files on a per-directory basis(i.e. .htaccess files in my case) by PHP? (1 answer) How do I include a php.ini file in another php.ini file? (7 answers) how to set environment variables in apache xampp ? (1 answer) Closed 2 years ago . I've installed PHP 7.2.3 on my machine running on Windows 10 . I've installed PHP and Apache httpd 4.29 using latest copy of XAMPP package . I come

Scandir Own filter function

徘徊边缘 提交于 2020-01-06 15:25:36
问题 I must write 2 functions, filter - names > 5 chars and I must sort them by types. Filtr function should look like this ? int (* filter) (const struct dirent* entry) { if ( (strlen(entry>d_name) - 1 ) > 5 ) { return entry; } } How about sort, in dirent its dirent->d_type, but how to sort ? 回答1: Have you considered taking a look at the man 3 scandir page? (I find the Linux man-pages project man pages most up-to-date for C library and system level programming.) If we have a function that needs

How to search file in folder by using php?

落花浮王杯 提交于 2020-01-05 07:32:03
问题 I have a folder called allfiles , and there are some files in this folder, such as 1212-how-to-sddk-thosd.html 3454-go-to-dlkkl-sdf.html 0987-sfda-asf-fdf-12331.html 4789-how-to-fdaaf-65536.html I use scandir to list all files, and now I need to find the file by with keywords, example to-dlkkl is the keyword, and I will get the file 3454-go-to-dlkkl-sdf.html . Glob seems not work, and opendir and readdir are not work well, any ideas? 回答1: Use loop foreach and strpos function: $files = scandir

How to search file in folder by using php?

雨燕双飞 提交于 2020-01-05 07:31:51
问题 I have a folder called allfiles , and there are some files in this folder, such as 1212-how-to-sddk-thosd.html 3454-go-to-dlkkl-sdf.html 0987-sfda-asf-fdf-12331.html 4789-how-to-fdaaf-65536.html I use scandir to list all files, and now I need to find the file by with keywords, example to-dlkkl is the keyword, and I will get the file 3454-go-to-dlkkl-sdf.html . Glob seems not work, and opendir and readdir are not work well, any ideas? 回答1: Use loop foreach and strpos function: $files = scandir

How to properly use scandir() in c?

若如初见. 提交于 2020-01-01 03:43:31
问题 I am trying to store list of files in a char** variable. scandir() finishes properly but I get a segmentation fault when trying to print the char**. Here's the code: int main() { char** fileList; int noOfFiles; char* path = "."; makeList(&fileList, &noOfFiles, path); return 0; } void makeList(char ***fileList, int* noOfFiles, char* path){ struct dirent **fileListTemp; *noOfFiles = scandir(path, &fileListTemp, NULL, alphasort); int i; fileList = (char***)malloc(sizeof(char***)); *fileList =