function preg_ls($path = ".", $rec = false, $pat = "/.*/") {
// it's going to be used repeatedly, ensure we compile it for speed.
$pat = preg_replace("|(/.*/[^S]*)|s", "\\1S", $pat);
//echo($pat);
//Remove trailing slashes from path
while (substr($path, -1, 1) == "/")
$path = substr($path, 0, -1);
//also, make sure that $path is a directory and repair any screwups
if (!is_dir($path)) $path = dirname($path);
//assert either truth or falsehoold of $rec, allow no scalars to mean truth
if ($rec !== true)
$rec = false;
//get a directory handle
$d = dir($path);
//initialise the output array
$ret = Array();
//loop, reading until there's no more to read
while (false !== ($e = $d->read())) {
//Ignore parent- and self-links
if (($e == ".") || ($e == "..")) continue;
//If we're working recursively and it's a directory, grab and merge
if ($rec && is_dir($path . "/" . $e)) {
$ret = array_merge($ret, preg_ls($path . "/" . $e, $rec, $pat));
continue;
}
//If it don't match, exclude it
if (!preg_match($pat, $e))
continue;
//In all other cases, add it to the output array
//echo ($path . "/" . $e . "
");
$ret[] = $path . "/" . $e;
}
//finally, return the array
echo json_encode($ret);
}
Ich erhalte eine Fehlermeldung in dieser Zeile: [code]$ret = array_merge($ret, preg_ls($path . "/" . $e, $rec, $pat)); [/code] Fehler ist:
array_merge() Argument #2 ist kein Array
Ich weiß nicht, wie ich das lösen soll. [code]function preg_ls($path = ".", $rec = false, $pat = "/.*/") { // it's going to be used repeatedly, ensure we compile it for speed. $pat = preg_replace("|(/.*/[^S]*)|s", "\\1S", $pat); //echo($pat); //Remove trailing slashes from path while (substr($path, -1, 1) == "/") $path = substr($path, 0, -1); //also, make sure that $path is a directory and repair any screwups if (!is_dir($path)) $path = dirname($path); //assert either truth or falsehoold of $rec, allow no scalars to mean truth if ($rec !== true) $rec = false; //get a directory handle $d = dir($path); //initialise the output array $ret = Array(); //loop, reading until there's no more to read while (false !== ($e = $d->read())) { //Ignore parent- and self-links if (($e == ".") || ($e == "..")) continue; //If we're working recursively and it's a directory, grab and merge if ($rec && is_dir($path . "/" . $e)) { $ret = array_merge($ret, preg_ls($path . "/" . $e, $rec, $pat)); continue; } //If it don't match, exclude it if (!preg_match($pat, $e)) continue; //In all other cases, add it to the output array //echo ($path . "/" . $e . " "); $ret[] = $path . "/" . $e; } //finally, return the array echo json_encode($ret); } [/code]
Ich habe versucht, die Kosten einer Indirektion zu messen, da das Stapeln von Indirektionen übereinander die Leistung speziell abbauen sollte. /> Virtuelle Funktionsaufruf. Code
#include
#include...
Die native CPP -Bibliothek (unter Verwendung von Multi -Threading -Bibliothek wie Arm Neon), die sehr schnell mit nativem Android -ausführbaren Datei ausgeführt wird, wird bei der Integration in die...
Die native CPP -Bibliothek (unter Verwendung von Multi -Threading -Bibliothek wie Arm Neon), die sehr schnell mit nativem Android -ausführbaren Datei ausgeführt wird, wird bei der Integration in die...
Ich habe (aus der CLI) mit den Verschlüsselungsbeispielen unter
experimentiert und möchte wissen, wie es geht Behandeln Sie eine größere Datei wie eine SQLite -Datenbankdatei mit wenigen GB. Ich...