Convert some HTML entities to characters in PHP

Description

The following code shows how to convert some HTML entities to characters.

Example


  //from  www  .ja v  a2 s .c  o m
<?php
    $str = "XML &amp; &#039;HTML&#039;";
    echo html_entity_decode($str, ENT_COMPAT); // Will only convert double quotes
    echo "<br>";
    echo html_entity_decode($str, ENT_QUOTES); // Converts double and single quotes
    echo "<br>";
    echo html_entity_decode($str, ENT_NOQUOTES); // Does not convert any quotes
?>

The code above generates the following result.





















Home »
  PHP Tutorial »
    Data Types »




Array
Array Associative
Array Util
ArrayObject
Data Types
Date
Date Format
DateTime
Number
String
String Escape
String Filter
String HTML
String Type
Timezone