PHP Repeating Print Statement
<p>I'm having an issue with a PHP print statement that repeats the output continuously for about 40 or 50 times, then stops.  I thought it was supposed to print only one line.  I'm still somewhat new to PHP, so I don't understand what I'm doing wrong.  The code in question is located at the bottom of the snippet.</p>

<p>Thanks in advance.....</p>

<pre><code> &lt;?php
$query = $_POST['query'];
find_files('.');

function find_files($seed) {
    if(! is_dir($seed)) return false;

    $files = array();
    $dirs = array($seed);

    while(NULL !== ($dir = array_pop($dirs))) {
        if($dh = opendir($dir)) {
            while( false !== ($file = readdir($dh))) {
                if($file == '.' || $file == '..') continue;
                $path = $dir . '/' . $file;
                if(is_dir($path)) { 
                    $dirs[] = $path; 
                } else { 
                    if(preg_match('/^.*\.(php[\d]?|js|txt)$/i', $path)) { 
                        check_files($path); 
                    }
                }
            }
            closedir($dh);
        }
    }
}

function check_files($this_file) {
    $query = $_POST['query'];
    $str_to_find = $query;

    if ((isset($str_to_find)) &amp;&amp; (empty($str_to_find))) {
        print '&lt;p&gt;Your search produced no results&lt;/p&gt;';
    } else {
        if(!($content = file_get_contents($this_file))) { 
            echo("&lt;p&gt;Could not check $this_file&lt;/p&gt;\n"); 
        } else { 
            if(stristr($content, $str_to_find)) { 
                echo("&lt;p&gt;$this_file -&gt; contains $str_to_find&lt;/p&gt;\n"); 
            }
        }
        unset($content);
    }
}
?&gt;
</code></pre>
