how can i make a function see a variable outside it
<p>How can I place a variable inside a function when it is run in order to preg_match the right information.  Here is my existing code:</p>

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

<p>What I am attempting to do is pull the $username variable from outside the function and allow it to be seen within it so I can pull the right matches in my while loop.  While the previous comes back blank, if i do the following it works:</p>

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