php class pass in undefined variables
<p>I am trying to make a class that can process strings with un defined variables. Is this possible? or is there a better way?<br /><br />
For instance, if I have the following and would like this class Looper to take <code>$str_1</code> and output it with the variables <code>$fname</code> and <code>$lname</code> filled out ... then somewhere else i can reuse Looper class and process <code>$str_2</code> since they both need <code>$fname</code> and <code>$lname</code>.</p>

<pre><code>class Looper {
    public function processLoop($str){
        $s='';
        $i=0;
        while ($i &lt; 4){
            $fname = 'f' . $i;
            $lname = 'l' . $i;

            $s .= $str . '&lt;br /&gt;';
            $i++;
        }
        return $s;
    }
}

$str_1 = "First Name: $fname, Last Name: $lname";
$rl = new Looper;
print $rl-&gt;processLoop($str_1);

$str_2 = "Lorem Ipsum $fname $lname is simply dummy text of the printing and typesetting industry";
print $rl-&gt;processLoop($str_2);
</code></pre>
