...

View Full Version : Search Directory by PHP



mehdi110
02-26-2008, 11:45 AM
i used this code to Search directory


<?php
if ($handle = opendir('./')) {
while (false !== ($file = readdir($handle))) {
$filesplit = explode(".", $file);
$check = $filesplit[0];
$keyword=$_GET['search'];
if(ereg($keyword, $check))
{
$check .= ".$filesplit[1]";
$valid[] = $check;
}
}
for($index = 0; $index < count($valid); $index++)
{
echo"<br>$valid[$index]";
}
closedir($handle);

}
?>

but it only search the main directory, not the Subdirectories.... can someone please customize it so that Subdirectories also be searched too...



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum