Page 1 of 1

If a word is found, display something

Posted: Mon Apr 05, 2004 12:57 am
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!

Posted: Mon Apr 05, 2004 1:12 am
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'); 
?>

Posted: Mon Apr 05, 2004 2:55 am
by apollovega
Thanks, :-) I'll see what I can work with, from that.