PHP scandir

Education is not limited to just classrooms. It can be gained anytime, anywhere... - Ravi Ranjan (M.Tech-NIT)

PHP : scandir() function

Last update on January 25 2017 11:38:38 (UTC/GMT +8 hours)

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 :

  1. <?php  

  2. print_r(scandir('test'));  

  3. ?>