PHP: scandir() function
Description
The scandir() function generates a list of file and directory inside a given path.
Version:
(PHP 4 and above)
Syntax:
scandir(directory, sort, context)
Parameters:
Name | Description | Required / Optional |
Type |
---|---|---|---|
directory | Specifies the directory. | Required | Date |
sort | If used then sort order is alphabetical in descending order. The default is alphabetical ascending order. | Optional | Integer |
context | Context is a set of parameters and wrapper specific option which modifies or enhance the behavior of a string. | Optional | Resource |
Return value:
An array of filenames on success, or FALSE on failure.
Value Type: Array
Example:
<?php
print_r(scandir('test'));
?>
See also
Previous: rewinddir
Next: Installing and configuring PHP for Math functions
It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.
https://w3resource.com/php/function-reference/scandir.php
- Weekly Trends and Language Statistics
- Weekly Trends and Language Statistics