Search code examples
phphtmlstringhtml-entitiesfractions

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?


Solution

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