Re: Copy of Ed Lazor's response : find and replace in php

From: Date: Tue, 02 Jul 2002 18:27:08 +0000
Subject: Re: Copy of Ed Lazor's response : find and replace in php
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-104987@lists.php.net to get a copy of this message
Thanks Ed, I would like to do that, but I'm not hard coding the letters myself. I'm trying to provide a way for others (to provide the text, who know nothing about the underlying processes) and do the search and replaces on the fly. Henry "Henry" <henry@teacake.f9.co.uk> wrote in message news:20020702182324.58256.qmail@pb1.pair.com... > Nothing will be inserted if the variable is empty, so you could just use > $firstname, $product, $date, etc. inside your "letter". The main problem is > adding logic to your "letter" to respond appropriately based on the value of > different variables. For example: > > $MailBody = ""; > if (empty($firstname)) > $MailBody .= "Dear Customer"; > else > $MailBody .= "Dear $firstname"; > > Note the use of .= to append to the string. > > -----Original Message----- > From: Henry [mailto:henry@teacake.f9.co.uk] > Sent: Tuesday, July 02, 2002 10:53 AM > To: php-general@lists.php.net > Subject: [PHP] find and replace in php > > > Imagine I have a piece of text > > "Dear [firstname] > > Thankyou for purchasing [product] on [date]. > > We're sure you'll be very [expectation]. > > Ta Very much." > > Whats the easiest way to replace all the things in square brackets with > variables of the same name. > > i.e. $firstname, $product, $date, $expectation > > Whilst ensuring that if the variable doesn't exist then it will be replaced > with "" (absolutely nothing). > > > Thankyou in advance > > Henry > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > **************************************************************************** > This message is intended for the sole use of the individual and entity to > whom it is addressed, and may contain information that is privileged, > confidential and exempt from disclosure under applicable law. If you are > not the intended addressee, nor authorized to receive for the intended > addressee, you are hereby notified that you may not use, copy, disclose or > distribute to anyone the message or any information contained in the > message. If you have received this message in error, please immediately > advise the sender by reply email and delete the message. Thank you very > much. > > "Henry" <henry@teacake.f9.co.uk> wrote in message > news:20020702175142.18923.qmail@pb1.pair.com... > > Imagine I have a piece of text > > > > "Dear [firstname] > > > > Thankyou for purchasing [product] on [date]. > > > > We're sure you'll be very [expectation]. > > > > Ta Very much." > > > > Whats the easiest way to replace all the things in square brackets with > > variables of the same name. > > > > i.e. $firstname, $product, $date, $expectation > > > > Whilst ensuring that if the variable doesn't exist then it will be > replaced > > with "" (absolutely nothing). > > > > > > Thankyou in advance > > > > Henry > > > > > >

« previous php.general (#104987) next »