Page 1 of 1

Insert HTML Tags in String

Posted: Tue Jun 12, 2007 10:12 pm
by TryAgain2
I am looking for a way to insert HTML tags into a string. For example, if I want to highlight part of a user's input how can I wrap it in HTML tags to underline or change its colour?

Example:

User input:

This is an example.

Then I want to hight one word:

This is an example.


I cannot find any string function/s that will do this.

Posted: Tue Jun 12, 2007 10:14 pm
by feyd
substr_replace(), preg_replace() among others can do this.

Posted: Thu Jun 14, 2007 2:45 am
by TryAgain2
Thanks, I thought I needed to insert the text, but I see now that the same thing can be accomplished with substr_replace.