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


PHP General Mailing List (
To unsubscribe, visit:

Reply via email to