Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Converting fractions to html entities

We've got some fraction information stored in the database, e.g. ¾ ½

Short of doing a search and replace, are there any inbuilt PHP functions that will automatically convert these to proper html entities?

like image 636
Tom Avatar asked Apr 07 '09 10:04

Tom


2 Answers

You can use the htmlentities() function. This will replace all special characters with their HTML equivalent. It should do the job.

like image 145
Sam152 Avatar answered Sep 28 '22 07:09

Sam152


htmlentities.

But you probably don't need to. Serve your page in an encoding that includes them (UTF-8, ISO-8859-1) and you can include those as literal, unescaped characters.

like image 34
bobince Avatar answered Sep 28 '22 08:09

bobince