ereg/str_replace ???

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
deadcowboy
Forum Newbie
Posts: 5
Joined: Tue Jun 11, 2002 4:49 pm

ereg/str_replace ???

Post 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~!
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post 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);
Post Reply