php-general Digest 7 Jun 2009 02:43:39 -0000 Issue 6162
Topics (messages 293686 through 293687):
Re: https setup
293686 by: Michael A. Peters
List files in a directory using filters and exclusions
293687 by: Rolando Santamaria Maso
Administrivia:
To subscribe to the digest, e-mail:
[email protected]
To unsubscribe from the digest, e-mail:
[email protected]
To post to the list, e-mail:
[email protected]
----------------------------------------------------------------------
--- Begin Message ---
PJ wrote:
Don't forget, you have to have a certificate, real or dummy for this to
work. :-)
Note that Firefox makes things difficult for non tech users with self
signed certs, so for a live site open to the public, you really do want
to spend the dough on a certificate from an authority.
--- End Message ---
--- Begin Message ---
Hi PHP community, here I bring a very simple and interesting function that
I made for a project, it's objetive is "to list path files in a directory
with the possibility of using filters and exclusions".
What do you think about?
-----------------------
function get_files($path, &$result, Array $exclusions, Array $filters)
{
@$dir_content = scandir($path);
if ($dir_content)
{
$end = count($dir_content);
$i = 2;
for ($i; $i < $end; $i++)
{
$path_and_element = $path.'/'.$dir_content[$i];
if (array_search($path_and_element, $exclusions) === false)
{
if (array_search(substr($dir_content[$i],
strlen($dir_content[$i]) - 4), $filters) !== false)
{
$result[] = $path_and_element;
}
if (is_dir($path_and_element))
{
get_files($path_and_element, $result, $exclusions,
$filters);
}
}
}
}
}
$path = '/var/www';
$result = array();
$exclusions = array('/var/www/drupal', '/var/www/wp');
$filters = array('.php');
get_files($path, $result, $exclusions, $filters);
echo "<pre>";
print_r($result);
die();
------------------------------------------------------------
Greetings!!!!
--- End Message ---