Jump to content

using glob() to look for all txt in directory


Imaulle

Recommended Posts

Close, however that will only get you the files in the current directory (not in any sub-directories). Try this:

 

<?php

$directory = 'sample';  // Replace with your starting directory
$it = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($directory));

while($it->valid())
{
    if(strtolower(substr($it->getFilename(), -4)) == '.txt')
    {
        var_dump($it->key());  // Not really needed, just used for debugging
        chmod($it->key(), 0777);
    }
    $it->next();
}

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.