<code><span><span>function</span><span>treeDirectory</span><span>(<span>$dir</span>)</span>{</span><span>$files</span> = <span>array</span>(); <span>$dirpath</span> = realpath(<span>$dir</span>); <span>$filenames</span> = scandir(<span>$dir</span>); <span>foreach</span> (<span>$filenames</span><span>as</span><span>$filename</span>) { <span>if</span> (<span>$filename</span>==<span>'.'</span> || <span>$filename</span>==<span>'..'</span>) { <span>continue</span>; } <span>$file</span> = <span>$dirpath</span> . DIRECTORY_SEPARATOR . <span>$filename</span>; <span>if</span> (is_dir(<span>$file</span>)) { <span>$files</span> = array_merge(<span>$files</span>, <span>self</span>::treeDirectory(<span>$file</span>)); } <span>else</span> { <span>$files</span>[] = <span>$file</span>; } } <span>return</span><span>$files</span>; }</code>
Oben wird erläutert, wie alle Dateien im angegebenen Verzeichnis in PHP gelesen werden. Ich hoffe, dass es Freunden, die sich für PHP-Tutorials interessieren, hilfreich sein wird, einschließlich relevanter Inhalte.