title: string replace in a file with php
body: <p>I am writing an email module for my web app that sends a html email to a user on completion of a task such as signing up.  Now as the formatting of this email may change I've decided to have a template html page that is the email, with custom tags in it that need to be replaced such as %fullname%.</p>
  
  <p>My function has an array in the format of array(%fullname% => 'Joe Bloggs'); with the key as the tag identifier and the value of what needs to replace it.</p>
  
  <p>I've tried the following:</p>
  
  <pre><code>        $fp = @fopen('email.html', 'r');
  
      if($fp)
      {
        while(!feof($fp)){
  
        $line = fgets($fp);                 
  
        foreach($data as $value){
  
            echo $value;
            $repstr = str_replace(key($data), $value, $line);           
  
        }
  
  
        $content .= $repstr;
  
        }
        fclose($fp);
      }
  </code></pre>
  
  <p>Is this the best way to do this? as only 1 tag get replaced at the moment... am I on the right path or miles off??</p>
  
  <p>thanks...</p>