PHP get directory All files with all directories saved to the array program This is a use of the Glob function to save all files and folders in the specified directory to the data, and then we then use a foreach again to determine the relevant data in the same OH.
PHP Tutorial Get directory All files with all directories saved to array program
This is a use of the Glob function to save the specified directory of all files and folders to the data, and then we then use a foreach to save the relevant data in the same OH.
$dirs = Array ();
foreach (Glob ("./*") as $d)
{
$tmp = Explode ('. ', $d);
$k = End ($tmp);
if (Is_file ($d) && $k = = ' php ')
{
$dirs [] = $d;
}
}
Print_r ($dirs);
Show directory all directories
$v =array ();
foreach (Glob ("./*") as $VV)
{
$tmp = Explode ('. ', $d);
$k = End ($tmp);
if (Is_dir ($VV))//directory and file difference is to use Is_dir or is_file to judge
{
$v [] = $VV;
}
}
Print_r ($v);
/*
Results
Array
(
[0] = =./1.php
[1] = =./10.php
[2] = =./11.php
[3] = =./3.php
[4] = =./4.php
[5] = =./5.php
[6] = =./7.php
[7] = =./8.php
[8] = =./9.php
)
Array
(
[0] = =./www.bkjia.com
)
*/
http://www.bkjia.com/PHPjc/445444.html www.bkjia.com true http://www.bkjia.com/PHPjc/445444.html techarticle php get directory All files with all directories saved to the array program This is a use of the Glob function to the specified directory of all files and folders to the data, and then we then use the foreach again to judge ...