Search Directory by PHP
Posted: Tue Feb 26, 2008 4:42 am
i used this code to Search directory
but it only search the main directory, not the Subdirectories.... can someone please customize it so that Subdirectories also be searched too...
Code: Select all
<?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);
}
?>