how do I search directories and their subdirectories for all files named "index.php" then return their path? (to an array)
>>58061538
nb: the files I need are several folders deep
>>58061538
Delete that picture and I will PM you the solution.
>>58061538
>>58061538
fixed it for you
>>58061538
What is everyone's preferred browser? Currently using Waterfox.
>>58061538
Use Symfony's finder component. It's the easiest way.
<?php
system("find . -name 'index.php' > output");
$result = file("output");
echo var_dump($result);
?>
You should be ashamed. I don't even know php and was able to cook this up in 5 minutes.
>>58061896
Another solution. Saves them in an array
$lines = array();
exec("find . -name 'index.php'", $lines);
//echo print_r($lines);
>>58062010
Somewhat bored and optimized it a bit.<?php
function search($name, $path = ".", $maxDepth = -1, $array = array())
{
$allFiles = scandir($path);
foreach($allFiles as $file) {
if (($file == ".") || ($file == ".."))
continue;
if (is_dir($path."/".$file) && ($maxDepth != 0))
$array = search($name, $path."/".$file, $maxDepth - 1, $array);
if ($file == $name)
$array[] = $path."/".$file;
}
return $array;
}
header("content-type:text/plain");
print_r(search("index.php"));
?>
>>58063183
He's not racist, he's just a moron. But who am I to go against the will of the burgerland people
>>58061604
Haha, well meme'd fellow /pol/lack!
>>58061896
Hello, Pajeet.
Are you sure you're not a PHP programmer?
Because you certainly have the right coding style.
>>58061538
>PHP
Using php in 2016 kek
>>58064121
>Hello, Pajeet.
A Pajeet only uses windows silly. Looks like thinking isn't your strongest suit.
tbqh I never realized how easily the alt-right could be triggered until CTR showed up
>>58063219
Says the dude working a dead end job coding php with an ugly gf (if at all), no friends, fat or skinny fat, who has to ask /g/ for the most retarded question ever.
>>58064070
D E S P A I R