[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y ] [Search | Free Show | Home]

PHP

This is a blue board which means that it's for everybody (Safe For Work content only). If you see any adult content, please report it.

Thread replies: 18
Thread images: 4

File: 1480085542431.jpg (38KB, 471x365px) Image search: [Google]
1480085542431.jpg
38KB, 471x365px
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.
>>
File: Christopher Walken.jpg (220KB, 600x324px) Image search: [Google]
Christopher Walken.jpg
220KB, 600x324px
>>58061538
>>
File: 1480085542431.png (149KB, 471x365px) Image search: [Google]
1480085542431.png
149KB, 471x365px
>>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.
>>
File: A_joke_vs_autism.jpg (40KB, 825x274px) Image search: [Google]
A_joke_vs_autism.jpg
40KB, 825x274px
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
Thread posts: 18
Thread images: 4


[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y] [Search | Top | Home]

I'm aware that Imgur.com will stop allowing adult images since 15th of May. I'm taking actions to backup as much data as possible.
Read more on this topic here - https://archived.moe/talk/thread/1694/


If you need a post removed click on it's [Report] button and follow the instruction.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com.
If you like this website please support us by donating with Bitcoins at 16mKtbZiwW52BLkibtCr8jUg2KVUMTxVQ5
All trademarks and copyrights on this page are owned by their respective parties.
Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
This is a 4chan archive - all of the content originated from that site.
This means that RandomArchive shows their content, archived.
If you need information for a Poster - contact them.