PHP search to include subdirectories?

zaveri.vismay97

New Member
Messages
6
Reaction score
0
Points
0
I have this code running on vismayzaveri.co.cc/test.html
It returns the image which has "_small" and which has the file name without "_small"=to search text entered in text box.
however this function is limited to the directory and does not scan the subdirectories.
Can anyone help me on how to correct the function so that includes the sub directory in the search as well
<?php

/* settings */
$image_dir = 'vish/';
$per_column = 6;
$srch=$_GET["search"];

/* step one: read directory, make array of files */
if ($handle = opendir($image_dir))
{
while (false !== ($file = readdir($handle)))
{
if ($file != '.' && $file != '..')
{
if(stristr($file,'_small') && strtolower(str_ireplace('_small.jpg','',$file))==strtolower($srch))
{
$files[] = $file;
}
}
}
closedir($handle);
}

/* step two: loop through, format gallery */
if(count($files))
{
foreach($files as $file)
{
$count++;
echo '<a class="photo-link" rel="one-big-group" title="',str_replace('_small.jpg','',$file),'" href="',$image_dir,str_ireplace('_small.jpg','.html',$file),'"><img src="',$image_dir,$file,'" style="opacity:1;filter:alpha(opacity=100)"
onmouseover="this.style.opacity=0.5;this.filters.alpha.opacity=50"
onmouseout="this.style.opacity=1;this.filters.alpha.opacity=100"
border-style="none" border="0px" width="100" height="100" /></a>';
if($count % $per_column == 0) { echo '<div class="clear"></div>'; }
}
}
else
{
echo '<p>There are no images in this gallery.</p>';
}

?>
 
Top