Okay, I've been trying to do this for a while but I can't figure out how. I saw a great tutorial here, but its gone right now, I'm assuming the database was affected by the downtime yesterday, which is no problem, maybe you people can help me.
What I need is an easy to update script that'll replace certain words with phrases. The one I saw was set up like this:
Original Text => Replaced Text
Which was great cause it was no problem to update... Anyways what I'm going to use it for is to make staff names into mailto links, no matter where they are. The only problem I can see is that if possible I'd like it to replace only whole words because "StudioJaymz" would have the "Jaymz" replaced with a link, which would be hell cause its a hyperlink
Any help is appreciated, or if someone could point me to a good tutorial...
PHP Replace certain words?
Started by
Jaymz
, Oct 23 2004 08:51 AM
4 replies to this topic
#1
Posted 23 October 2004 - 08:51 AM
#2
Posted 23 October 2004 - 11:01 AM
http://www.dabu4u.co...caseinsensitive
just make sure that you escape your " tags if you ar putting a hyperlink in
just make sure that you escape your " tags if you ar putting a hyperlink in
#3
Posted 28 October 2004 - 09:25 AM
check http://us2.php.net/m...reg-replace.php for more info on the ereg-replace and other forms of replacing strings
one thing you may consider when using replacment functions is they normally replace what ever word you search for no matter where it is, or what's around it
so if you have a common word for a staff name, like "Joe", and somebody types "Joey", then the joe part of joey would become a hyperlink
one possible fix would be to add a space before/after the name you search for in a string (better explanation here)
one thing you may consider when using replacment functions is they normally replace what ever word you search for no matter where it is, or what's around it
so if you have a common word for a staff name, like "Joe", and somebody types "Joey", then the joe part of joey would become a hyperlink
one possible fix would be to add a space before/after the name you search for in a string (better explanation here)
#4
Posted 28 October 2004 - 03:37 PM
Thanks, I'll look into it
#5
Posted 09 November 2004 - 10:29 PM
use this:
$row = str_replace("first word", "!@#%^&*", $row); $row = str_replace("Second word", "!@#%^&*", $row);Just change the the inside area of the ( ) and if you want, add more lines that are identical to the first one but with different text to replace. It is easyer to make this in a seperate file and include it into the pages you want the text changed. This will also work with bb code as well, so you can make your own bb code.
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users