PHP 8.5.0 Alpha 4 available for testing

Voting

: zero minus zero?
(Example: nine)

The Note You're Voting On

kodlee at kodleeshare dot net
13 years ago
I needed to find a way to get the full path of all files in the directory and all subdirectories of a directory.
Here's my solution: Recursive functions!

<?php
function find_all_files($dir)
{
$root = scandir($dir);
foreach(
$root as $value)
{
if(
$value === '.' || $value === '..') {continue;}
if(
is_file("$dir/$value")) {$result[]="$dir/$value";continue;}
foreach(
find_all_files("$dir/$value") as $value)
{
$result[]=$value;
}
}
return
$result;
}
?>

<< Back to user notes page

To Top