If a word is found, display something

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
apollovega
Forum Newbie
Posts: 12
Joined: Thu Feb 19, 2004 3:34 pm

If a word is found, display something

Post by apollovega »

Okay, my question is pretty simple (specially to you advanced php'ers :) )
I was wondering if it were possible (and if so, how) you could achieve this... (bear with me as I'm pretty new to php hehe)

Basically, what I want this lil script to do is if the word "Nadia" (or whatever) is found at all on the entire page, to replace that word with a picture instead.. Think of it this way, the Emoticons on the side. Whenever someone types

Code: Select all

:-)
they get a :-) instead. That's exactly what I want to do. Any ideas as to how this is done? Thanks!
P.s, if you want you could just point me into the right direction and I could try my hand at figuring it out. Any help would be muchly appreciated.. Thanks!
User avatar
andre_c
Forum Contributor
Posts: 412
Joined: Sun Feb 29, 2004 6:49 pm
Location: Salt Lake City, Utah

Post by andre_c »

I hope this helps:

Code: Select all

<? 
$new_string = str_replace('word', '<img src=image />', 'text in which to search, replace this word for an image'); 
?>
apollovega
Forum Newbie
Posts: 12
Joined: Thu Feb 19, 2004 3:34 pm

Post by apollovega »

Thanks, :-) I'll see what I can work with, from that.
Post Reply