highlight_phrase($str, $phrase[, $tag_open = ''[, $tag_close = '']])
Parameters: |
|
---|---|
Returns: |
String with a phrase highlighted via HTML |
Return type: |
string |
Will highlight a phrase within a text string. The first parameter will contain the original string, the second will contain the phrase you wish to highlight. The third and fourth parameters will contain the opening/closing HTML tags you would like the phrase wrapped in.
Example:
$string = "Here is a nice text string about nothing in particular."; echo highlight_phrase($string, "nice text", '<span style="color:#990000;">', '</span>');
The above code prints:
Here is a <span style="color:#990000;">nice text</span> string about nothing in particular.
Note
This function used to use the <strong>
tag by default. Older browsers might not support the new HTML5 mark tag, so it is recommended that you insert the following CSS code into your stylesheet if you need to support such browsers:
mark { background: #ff0; color: #000; };
Please login to continue.