how can i set a global function from a while loop
<p>What I am attempting to do is setup a global variable for $ftp_user_name so I can place it within my function so that while the loop runs through the information it will preg_match correctly at the end of my ftp connections and output the list of files I am looking for.</p>

<pre><code>function is_txt($file) {
    global $ftp_user_name;
    return preg_match('/backup-[0-9]+\.[0-9]+\.[0-9]+_[0-9]{2}-[0-9]{2}-[0-9]{2}_'.$ftp_user_name.'.tar.gz/', $file) &gt; 0;
}

while($row = mysql_fetch_array($query)) {

    $ftp_dir = $row['ftpdir'];

    // main display loop

    if (empty($row['ftphost'])){

        $ftp_server = $row['domain'];
        $ftp_user_name = $row['cpuser'];
        $ftp_user_pass = $row['cppass'];

    }
    else
    {
        $ftp_server = $row['ftphost'];
        $ftp_user_name = $row['ftpuser'];
        $ftp_user_pass = $row['ftppass'];
    }
}
</code></pre>
