(PHP 5, PHP 7)
scandir — �г�ָ��·���е��ļ���Ŀ¼
$directory
[, int $sorting_order
[, resource $context
]] ) : array
����һ�� array��������
directory
�е��ļ���Ŀ¼��
directory
Ҫ�������Ŀ¼
sorting_order
Ĭ�ϵ�����˳���ǰ���ĸ�������С����ʹ���˿�ѡ����
sorting_order
����Ϊ
1����������˳���ǰ���ĸ�������С�
context
context
������˵�����ֲ��е�
Streams API һ�¡�
�ɹ��ذ������ļ����� array�����ʧ����
FALSE
����� directory
���Ǹ�Ŀ¼���ز���ֵ FALSE
������һ��
E_WARNING
���Ĵ���
�汾 | ˵�� |
---|---|
5.4.0 |
sorting_order now accepts constants. Any
nonzero value caused descending order in previous versions.
|
Example #1 һ���� scandir() ����
<?php
$dir = '/tmp';
$files1 = scandir($dir);
$files2 = scandir($dir, 1);
print_r($files1);
print_r($files2);
?>
�������̵���������ڣ�
Array ( [0] => . [1] => .. [2] => bar.php [3] => foo.txt [4] => somedir ) Array ( [0] => somedir [1] => foo.txt [2] => bar.php [3] => .. [4] => . )
Example #2 scandir() �� PHP 4 �е�ʵ��
<?php
$dir = "/tmp";
$dh = opendir($dir);
while (false !== ($filename = readdir($dh))) {
$files[] = $filename;
}
sort($files);
print_r($files);
rsort($files);
print_r($files);
?>
�������̵���������ڣ�
Array ( [0] => . [1] => .. [2] => bar.php [3] => foo.txt [4] => somedir ) Array ( [0] => somedir [1] => foo.txt [2] => bar.php [3] => .. [4] => . )
��������fopen ��װ�����ڴ˺����У� URL ����Ϊ�ļ������������ָ���ļ������ fopen()������ wapper �IJ�ͬ������μ� ֧�ֵ�Э��ͷ�װЭ����ע�����÷�������ṩ��Ԥ���������