コード例 #1
0
ファイル: funcions.php プロジェクト: projectesIF/Ateneu
function index_array($directory = "../../../data/pages/", $pattern = 'index.txt', $recursive = true)
{
    $array_items = array();
    if ($handle = opendir($directory)) {
        while (false !== ($file = readdir($handle))) {
            if ($file != "." && $file != "..") {
                if (is_dir($directory . "/" . $file)) {
                    if ($recursive) {
                        if (substr($file, 0, 4) != ".tmp" and substr($file, 0, 2) != "z_") {
                            $array_items = array_merge($array_items, index_array($directory . "/" . $file, $pattern, $recursive));
                        }
                    }
                    // No és un directori
                } else {
                    // mirar si s'inclou a la llista
                    $newdir = str_replace("//", "/", $directory) . '/';
                    $subdirs = has_subdirs($newdir);
                    $ext = substr(strtolower($file), -strlen($pattern));
                    if (!is_dir($file) && $ext == $pattern && $subdirs) {
                        $file = $directory . "/" . $file;
                        $array_items[] = preg_replace("/\\/\\//si", "/", $file);
                    }
                }
            }
        }
        closedir($handle);
    }
    foreach ($array_items as &$item) {
        $item = str_replace("../../../data/pages/", "", $item);
    }
    deleteFromArray($array_items, $pattern, $useOldKeys = FALSE);
    $result = natsort($array_items);
    return $array_items;
}
コード例 #2
0
ファイル: nglib.php プロジェクト: istrwei/youtube
function formatVListByType($vlist, $typelist, $typename = "type", $removeOtherType = false)
{
    $rtn = array();
    $f = explode(',', $typelist);
    foreach ($f as $t) {
        foreach ($vlist as $i) {
            $temp = stripos($i[$typename], $t);
            if ($temp === 0 | $temp > 3) {
                $rtn[] = $i;
                deleteFromArray($vlist, $i);
            }
        }
    }
    if (!$removeOtherType) {
        $rtn = array_merge($rtn, $vlist);
    }
    $rtn2 = array();
    $f = array("medium", "large", "hd720", "hd1080");
    foreach ($f as $t) {
        foreach ($rtn as $i) {
            if (strpos($i['quality'], $t) !== FALSE) {
                $rtn2[] = $i;
                deleteFromArray($rtn, $i);
            }
        }
    }
    $rtn2 = array_merge($rtn2, $rtn);
    return $rtn2;
}