sorry about the volume of this apiece.just thinking it will help you understand my frenzy script better. to start with, it is a simple 'intra' search script that opens include files contained in the dir the visitor wants to searchand match its content with the query. contents of the include files are in plain txt format like this: God is luv. we learn to walk by stumbling php forever and so on. here is the search funtion that does the 'opening' and matching : function search($file) { global $q, $a; $sd = opendir($file); while (($sf=readdir($sd)) !== false) { $line = file($sf); foreach ($line as $content) { if (preg_match($q, $content)) { if (!in_array($content, $a) { $a[] = $content; } } } $c = count($a); return $a; return $c; } it is included in this main script: foreach($_request as $r => $v) { //this declares $in and $q... $$r = $v; // ...which are the directories to be searched and query respectively } include ('dir-search-function.inc'); $q = strip_tags(strip_slashes(trim(strtolower($q)))); $a = array(); if ($in == 'whole') { // if visitor wants to search all directories $dh = opendir('dir/'); while (($d = readdir($dh)) !== false) { if (is_dir($d)) { search($d) ; } } } else { if (!empty($in)) { search('/dir/' . $in . '/'); // for something like 'dir/arts/' } } if ($c == 0) { // if no match echo 'Sorry, no link and comment was found to contain your query: <TT>$q</TT> in the <TT>$in</TT> directory.<BR>'; } else{ echo ' <TT>$c</TT> results were found for <TT>$q</TT> in the <TT>$in</TT> directory<br>'; foreach ($a as $value) { echo '$value'; } the scrap gave me bugs so guys i need help. by the way, i think you should take a closer look at the search function. im no good at writing functions(cant even do classes), so guess thats where the mistake is lurking. av fun. thanks. :) --------------------------------- A passion till tomorrow, Opeyemi Obembe | ng.clawz.com --------------------------------- Do you Yahoo!? Yahoo! Small Business - Try our new resources site!