Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ereg_replace template problem :-/

Status
Not open for further replies.

youradds

Programmer
Jun 27, 2001
817
GB
Is there a problem with ereg_replace, as to where it doesn't like doing replacements of a variable more than once, or on one line? I have the following code;

Code:
   global $email_user_signup, $admin_email;

   if ($email_user_signup) {

      $subject = "Advert Addition...";
      $message = "Someone has just add a new advert. The details are; \n\nUsername:$_username\n\nPassword:$_password\n\n\n\nEmail: $_email\n\n\n\nDescription: $_description\n\nTitle: $_title\n\nURL: $_url\n\nIf there is anything you don't think is reight here, please be sure to go in via the admin panel, and do a search for this advert, and edit/delete it as is appropriate...";
      mail("$admin_email", $subject, $message,
         "From: $admin_email\r\n"
        ."Reply-To: $admin_email\r\n");
      }

  $input = file("user-signup-done.html");

  // now print line by line, changing tags we need from thsere...
  foreach ($input as $line) {

     $line = ereg_replace(":::email:::",       $_email       , $line);
     $line = ereg_replace(":::url:::",         $_url         , $line);
     $line = ereg_replace(":::title:::"      , $_title       , $line);
     $line = ereg_replace(":::description:::", $_description , $line);
     $line = ereg_replace(":::username:::",    $_username    , $line);
     $line = ereg_replace(":::password:::",    $_password    , $line);

     echo $line;

  }

The template file contains this line;

<a href=&quot;signup.php?action=email_new&email=:::email:::&username=:::username:::&password=:::password:::&quot;>

The output of the template reading this line, is the same (i.e no changed tags)

Any tags above it, change fine :-/

Anyone got any ideas?

Cheers

Andy
 
You aren't concatinating all the strings together, try:

foreach ($input as $line) {

$line = ereg_replace(&quot;:::email:::&quot;, $_email , $line);
$line .= ereg_replace(&quot;:::url:::&quot;, $_url , $line);
$line .= ereg_replace(&quot;:::title:::&quot; , $_title , $line);
$line .= ereg_replace(&quot;:::description:::&quot;, $_description , $line);
$line .= ereg_replace(&quot;:::username:::&quot;, $_username , $line);
$line .= ereg_replace(&quot;:::password:::&quot;, $_password , $line);

echo $line;

}
--BB
 
There is no need to concacinate the strings, cos its editing the same line over and over again, trying to find the instances of it, and then replacing the tag with the value ;)

Cheers anyway :)

Andy
 
Apologies for the above post, I didn't read that very well.

PCRE is best :) --BB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top