Page 1 of 1

ereg/str_replace ???

Posted: Wed Jun 12, 2002 5:43 pm
by deadcowboy
i need to know how i can make it so that when a user replies to a message, the subject is not editable, but instead just appears on the page with only 1 instance of Re:

for instance, i DONT want it to look like this

subject
RE: subject
RE: RE: subject
RE: RE: RE: subject

etc. etc.


i DO want it to look like this

subject
RE: subject
RE: subject
RE: subject


how can i do this?

the code i am using right now is:

$contents = str_replace("<!--SUBJECT-->",$subject,$contents);

which replaces all instances of <!--SUBJECT--> on my reply page with the actual subject.... now how can i get it to only see one RE:

if a user would reply to a subject called "RE: Subject" the reply subject will say "RE: RE: Subject"

how can i make it just 1??

anyone?
thanks~!

Posted: Wed Jun 12, 2002 6:55 pm
by volka
try

Code: Select all

$string = "Re:Re: Re:Test"; // as example
$string = preg_replace('/(^&#1111;Rr]&#1111;Ee]:\s?)?(&#1111;Rr]&#1111;Ee]:\s?)*(.*)/', '\1\3', $string);
print($string);