Usage:
$rr = new RegexReplace();
$str = "Hello {name,fallback=Customer}, this is a message sent to {email}, we'll be in touch in writing at {address,fallback=Your Postal Address}";
$data1 = array(
'name' => "John Smith",
'email' => "[email protected]",
'address' => NULL,
);
$data2 = array(
'name' => NULL,
'email' => "[email protected]",
'address' => "123 Berkshire Road, London",
);
echo $rr->execute($str, $data1);
//Hello John Smith, this is a message sent to [email protected], we'll be in touch in writing at Your Postal Address
echo $rr->execute($str, $data2)
//Hello Customer, this is a message sent to [email protected], we'll be in touch in writing at 123 Berkshire Road, London