pg. pg. - 9 months ago 67
HTML Question

Ignoring superscript in title tags

I work on a database driven website. Most pages' titles are the names of partners we have, and served from a database using php.

For example one page might be called "Experian". The problem is that some of the values for partner names don't work because the values are things like

$partnername22 = Discover<sup>tm</sup> Magazine

I can't use this for a title because superscript can't show up in a title, and I can't change the value because many other things depend on it. Is there a trick I can pull to make the browser ignore the superscript tags if they are in the title?



<title><?php echo $offer22name ?>is a magazine</title>

change to:

<title><?php echo preg_replace('|<sup>(.*?)</sup>|', '($1)', $offer22name) ?> is a magazine</title>

But like Bryan mentioned, you should use PHP's strip_tags() in this scenario. So:

<title><?php echo strip_tags($offer22name) ?> is a magazine</title>