Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Finding text and replace it??

Status
Not open for further replies.

Naits

Programmer
Oct 10, 2001
90
NO
How can i find text in an variable an replace it with some other text like:

$text ="Hello :)" //and replace :) with
<img src=&quot;myserver/smilies/smile.gif&quot;>

 
you need to use regular expressions.
something like this:
Code:
$text =&quot;Hello :)&quot;; //and replace :) with
$text = ereg_replace (&quot;:)&quot;, &quot; <img src=\&quot;myserver/smilies/smile.gif\&quot;>&quot;, $text);
to read more about it go to:
(-:
 
stakadush, why regular expressions? The following should work:
Code:
$text = str_replace(&quot;:)&quot;, &quot;<img src='myserver/smilies/smile.gif'>&quot;, &quot;Hello :)&quot;);
No? Should cut down on processing that way too.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top