this should work:
function Addre($subject) {
if (preg_match("/^re:/i", $subject)) { // if subject already begins with re:
return $subject;
} else { // if a "Re:" needs to be added:
$x = "Re: " . $subject;
return $x;
}
}
I used perl compatible patern matching, because its supposed to be faster. I checked the code, and it should work fine.
usage is like this:
$text = "Hello World!";
$text = Addre($text);
// outputs "Re: Hello World!"
echo $text;