Tools, FAQ, Tutorials:
Putting Directory Entries into an Array in PHP
How To Dump the Contents of a Directory into an Array in PHP?
✍: FYIcenter.com
If you want to get the contents of a directory into an array, you can use the scandir() function. It gets a list of all the files and sub directories of the specified directory and returns the list as an array. The returning list also includes two specify entries: (.) and (..). Here is a PHP script example on how to use scandir():
<?php
mkdir("/temp/download");
$array["one"] = "Download PHP scripts at dev.fyicenter.com.\r\n";
$array["two"] = "Download Perl scripts at dev.fyicenter.com.\r\n";
$bytes = file_put_contents("/temp/download/todo.txt", $array);
$files = scandir("/temp/download");
print_r($files);
?>
This script will print:
Array
(
[0] => .
[1] => ..
[2] => todo.txt
)
⇒ Reading Directory Entries in PHP
2016-11-20, ∼3267🔥, 0💬
Popular Posts:
How to use the JSON to XML Conversion Tool at utilities-online.info? If you want to try the JSON to ...
How to create the Hello-3.0.epub package? I have all required files to create Hello-3.0.epub. To cre...
How to call a function from a VC# class provided in a library? If you want to call a function from a...
How To Use an Array as a Queue in PHP? A queue is a simple data structure that manages data elements...
What is Fabric CA (Certificate Authority)? Fabric CA (Certificate Authority) is a component of Hyper...