本文整理汇总了PHP中dirToArray函数的典型用法代码示例。如果您正苦于以下问题:PHP dirToArray函数的具体用法?PHP dirToArray怎么用?PHP dirToArray使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了dirToArray函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: dirToArray
function dirToArray($dir)
{
$contents = array();
# Foreach node in $dir
foreach (scandir($dir) as $node) {
# Skip link to current and parent folder
if ($node == '.') {
continue;
}
if ($node == '..') {
continue;
}
# Check if it's a node or a folder
if (is_dir($dir . DIRECTORY_SEPARATOR . $node)) {
# Add directory recursively, be sure to pass a valid path
# to the function, not just the folder's name
$contents[$node] = dirToArray($dir . DIRECTORY_SEPARATOR . $node);
} else {
# Add node, the keys will be updated automatically
$contents[] = $node;
}
}
# done
return $contents;
}
示例2: echoErrors
function echoErrors($dirname)
{
$dirarr = dirToArray($dirname);
if (count($dirarr) > 0) {
echo "<ul>";
foreach ($dirarr as $key => $value) {
$l = $dirname . $value;
echo "<li><div class='error_item'><a href='{$l}'>" . $value . "</a></div></li>";
}
echo "</ul>";
} else {
echo "nothing to show";
}
}
示例3: dirToArray
function dirToArray($dir)
{
$result = array();
$cdir = scandir($dir);
foreach ($cdir as $key => $value) {
if (!in_array($value, array(".", ".."))) {
if (is_dir($dir . DIRECTORY_SEPARATOR . $value)) {
$result[$value] = dirToArray($dir . DIRECTORY_SEPARATOR . $value);
} else {
$result[] = $value;
}
}
}
return $result;
}
示例4: dirToArray
function dirToArray($dir)
{
$result = array();
$cdir = scandir($dir);
foreach ($cdir as $value) {
if (!in_array($value, array(".", ".."))) {
if (is_dir($dir . DIRECTORY_SEPARATOR . $value)) {
$result[] = array('name' => substr($value, strpos($value, '.') + 1, strlen($value)), 'children' => dirToArray($dir . DIRECTORY_SEPARATOR . $value), 'path' => $dir . DIRECTORY_SEPARATOR . $value . DIRECTORY_SEPARATOR);
} else {
$result[pathinfo($value, PATHINFO_EXTENSION)] = array('path' => $dir . DIRECTORY_SEPARATOR . $value, 'name' => pathinfo($value, PATHINFO_FILENAME));
}
}
}
return $result;
}
示例5: dirToArray
function dirToArray($dir)
{
$result = array();
$cdir = scandir($dir);
foreach ($cdir as $key => $value) {
if (!in_array($value, array(".", "..", ".DS_Store", ".gitkeep", "controllers", "autoload.php"))) {
if (is_dir($dir . DIRECTORY_SEPARATOR . $value)) {
$result = array_merge($result, dirToArray($dir . DIRECTORY_SEPARATOR . $value));
} else {
if (!preg_match("/^_(.*)+\$/i", $value)) {
$result[] = $dir . '/' . $value;
}
}
}
}
return $result;
}
示例6: dirToArray
function dirToArray($dir)
{
$ignore = array('.', '..', 'js', 'src', 'css', 'fonts', 'build', 'examples', 'assets');
$result = array();
$root = scandir($dir);
$dirs = array_diff($root, $ignore);
foreach ($dirs as $key => $value) {
if (is_dir($dir . DIRECTORY_SEPARATOR . $value)) {
$result[$value] = dirToArray($dir . DIRECTORY_SEPARATOR . $value);
} else {
if (substr($value, -3) == '.js') {
$result[] = $value;
}
}
}
return $result;
}
示例7: dirToArray
function dirToArray($dir)
{
$ignore = array('.', '..', '_site', 'assets', 'gfx', 'states', 'book', 'filters', 'misc', 'golf');
$result = array();
$root = scandir($dir);
$dirs = array_diff($root, $ignore);
foreach ($dirs as $key => $value) {
if (is_dir($dir . DIRECTORY_SEPARATOR . $value)) {
$result[$value] = dirToArray($dir . DIRECTORY_SEPARATOR . $value);
} else {
if (substr($value, -3) == '.js') {
$result[] = $value;
}
}
}
return $result;
}
示例8: dirToArray
function dirToArray($dir) {
$contents = array();
foreach (scandir($dir) as $node) {
if ($node == '.') continue;
if ($node == '..') continue;
if (preg_match('/^\./',$node)) continue;
if (is_dir($dir.DS.$node)) {
if($node == 'admin') continue;
if($dir === ROOT.DS.'scripts' && $node === 'tiny_mce') continue;
$contents[$node] = dirToArray($dir.DS.$node);
continue;
}
else {
$contents[] = $node;
}
}
return $contents;
}
示例9: dirToArray
function dirToArray($dir)
{
global $total;
$ignore = array('.', '..', 'assets', 'css', 'export', 'fonts', 'js', 'lib', 'src');
$result = array();
$root = scandir($dir);
$dirs = array_diff($root, $ignore);
foreach ($dirs as $key => $value) {
if (is_dir($dir . DIRECTORY_SEPARATOR . $value)) {
$result[$value] = dirToArray($dir . DIRECTORY_SEPARATOR . $value);
} else {
if ($value !== 'index.html' && substr($value, -5) === '.html') {
$result[] = $value;
$total++;
}
}
}
return $result;
}
示例10: dirToArray
function dirToArray($dir, $firstLevel = true)
{
if (!$firstLevel) {
$result = "<ul style='display:none'>";
} else {
$result = "<ul id='dirList'>";
}
$cdir = scandir($dir);
foreach ($cdir as $key => $value) {
if (!in_array($value, array(".", ".."))) {
if (is_dir($dir . DIRECTORY_SEPARATOR . $value)) {
$result .= "<li><a href='#' class='collection-item' id='" . $dir . DIRECTORY_SEPARATOR . $value . "'>{$value}</a>";
$result .= dirToArray($dir . DIRECTORY_SEPARATOR . $value, false);
$result .= "</li>";
}
}
}
return $result . "</ul>";
}
示例11: dirToArray
/**
* dirToArray
* Returns a recursive array of the recursive directories
*
* $dir:
* Folder to scan, starting at one folder up
* Ignores ., .. and "media"
* //TODO: Ignore an array argument of words
*
* @return:
* Array containing the recursive folder scan
* Ex:
* [Category] => [Content] =>
* [Content 2] =>
* [Category 2] =>
*
*/
function dirToArray($dir)
{
/* Splitting the directory */
$dirPath = explode(DIRECTORY_SEPARATOR, dirname(__FILE__));
/* Moving to parent, adding selected directory */
$dir = implode(DIRECTORY_SEPARATOR, array_pop($dirPath)) . "{$dir}";
/* Grabbing the values */
$result = array();
$cdir = scandir($dir);
foreach ($cdir as $key => $value) {
/* Ignore current dir, previous dir and media folder */
if (!in_array($value, array(".", "..", "media"))) {
if (is_dir($dir . DIRECTORY_SEPARATOR . $value)) {
$result[$value] = dirToArray($dir . DIRECTORY_SEPARATOR . $value);
}
}
}
return $result;
}
示例12: dirToArray
function dirToArray($dir, $fix = "", &$first = true)
{
$handle = opendir($dir);
while (($file = readdir($handle)) !== false) {
if ($file == '.' || $file == '..') {
continue;
}
if (is_dir($dir . DIRECTORY_SEPARATOR . $file)) {
dirToArray($dir . DIRECTORY_SEPARATOR . $file, $fix . $file . "/", $first);
} elseif (!str_ends_with($file, ".php") && !str_ends_with($file, ".md5") && !str_ends_with($file, ".dat") && !str_starts_with($file, "installer")) {
if ($first) {
$first = false;
} else {
print "\r\n";
}
print $fix . $file;
}
}
closedir($handle);
}
示例13: dirToArray
function dirToArray($dir)
{
global $header;
global $footer;
$ignore = array('.', '..', 'assets', 'js', 'css', 'fonts', 'lib');
$result = array();
$root = scandir($dir);
$dirs = array_diff($root, $ignore);
foreach ($dirs as $key => $value) {
if (is_dir($dir . DIRECTORY_SEPARATOR . $value)) {
$result[$value] = dirToArray($dir . DIRECTORY_SEPARATOR . $value);
} else {
if (substr($value, -3) === '.js') {
$src = file_get_contents($dir . $value);
$output = $header . $src . $footer;
$filename = str_replace('.js', '.html', $value);
file_put_contents("../{$filename}", $output);
echo "{$value} <br>";
}
}
}
return $result;
}
示例14: dirToArray
function dirToArray($dir, $level = 0, $exclude = "")
{
//recursive function if $level !=0
// if level ==1 , only scan given $dir
if (!is_dir($dir)) {
return false;
}
$result = array();
$cdir = scandir($dir);
foreach ($cdir as $key => $value) {
if (is_dir($dir . DIRECTORY_SEPARATOR . $value) and $level === 1) {
continue;
}
if (!in_array($value, array(".", "..", $exclude))) {
if (is_dir($dir . DIRECTORY_SEPARATOR . $value) and $level === 0) {
$result[$value] = dirToArray($dir . DIRECTORY_SEPARATOR . $value, $level, $exclude);
} else {
$result[] = $value;
}
}
}
return $result;
}
示例15: dirToArray
function dirToArray($dir)
{
global $src;
$ignore = array('.', '..');
$fileIgnore = array('p2.js');
$result = array();
$root = scandir($dir);
$dirs = array_diff($root, $ignore);
foreach ($dirs as $key => $value) {
$path = realpath($dir . DIRECTORY_SEPARATOR . $value);
if (is_dir($path)) {
$result[$value] = dirToArray($path);
} else {
if (substr($value, -3) == '.js') {
if (!in_array($value, $fileIgnore)) {
$index = str_replace($src, "", $path);
$index = substr($index, 1);
$result[substr($value, 0, -3)] = $index;
}
}
}
}
return $result;
}