The built-in PHP scanddir() function is used for returning an array of files and directories from the passed directory.
array scandir ( string $directory [, int $sorting_order [, resource $context]] );
|Sr.No||Parameter & Description|
The directory that will be scanned.
It specifies the sort order. Default is 0 (ascending). If set to 1, it indicates descending order.
It specifies the context of the directory handle. Context is a set of options that can modify the behavior of a stream.
<?php $dir = '/newfolder'; $files1 = scandir($dir); $files2 = scandir($dir, 1); print_r($files1); print_r($files2); ?>
Array (  => .  => ..  => abc.php  => bbc.txt  => somedir ) Array (  => somedir  => indiabbc.txt  => status999.php  => ..  => . )
Do feel free to ask your questions where necessary and we will attend to them as soon as possible. If this tutorial was helpful to you, you can use the share button to share this tutorial.
Follow us on our various social media platforms to stay updated with our latest tutorials. You can also subscribe to our newsletter in order to get our tutorials delivered directly to your emails.
Thanks for reading and bye for now.