当前位置: 首页>>代码示例>>PHP>>正文


PHP dirToArray函数代码示例

本文整理汇总了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;
}
开发者ID:hendrik-weiler,项目名称:DataEncrypterService,代码行数:25,代码来源:index.php

示例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";
    }
}
开发者ID:peepkungas,项目名称:EstNer,代码行数:14,代码来源:index.php

示例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;
}
开发者ID:VianneyR,项目名称:ShowYourTalents,代码行数:15,代码来源:scanYourDir.php

示例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;
}
开发者ID:bobkingof12vs,项目名称:HumbleData,代码行数:15,代码来源:home.php

示例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;
}
开发者ID:opsone,项目名称:wordpress-theme-kit,代码行数:17,代码来源:autoload.php

示例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;
}
开发者ID:MichelCarroll,项目名称:phaser-examples,代码行数:17,代码来源:list.php

示例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;
}
开发者ID:MichelCarroll,项目名称:phaser-examples,代码行数:17,代码来源:index-vj.php

示例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;
}
开发者ID:nathanjsweet,项目名称:Reflexion,代码行数:18,代码来源:upload-files.php

示例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;
}
开发者ID:nilocesar,项目名称:boxe2d,代码行数:19,代码来源:index.php

示例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>";
}
开发者ID:kvalium,项目名称:imgui,代码行数:19,代码来源:scanDir.php

示例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;
}
开发者ID:AntonyGarand,项目名称:smallBlog,代码行数:36,代码来源:functions.inc.php

示例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);
}
开发者ID:GoldenGnu,项目名称:jeveassets,代码行数:20,代码来源:list.php

示例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;
}
开发者ID:nilocesar,项目名称:boxe2d,代码行数:23,代码来源:index.php

示例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;
}
开发者ID:raphael-betemps,项目名称:reservoirlog-php,代码行数:23,代码来源:bases.php

示例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;
}
开发者ID:HJSR,项目名称:phaser,代码行数:24,代码来源:index.php


注:本文中的dirToArray函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。