Converts a number of HTML entities into their special characters.
Specifically deals with: &, <, >, ", and '.
$quote_style can be set to ENT_COMPAT to decode " entities, or ENT_QUOTES to do both " and '. Default is ENT_NOQUOTES where no quotes are decoded.
1 time — 0.000094 sec (very fast) | 50000 times — 1.08 sec (fast)
No Hooks.
Return
String. The decoded text without HTML entities.
Usage
wp_specialchars_decode( $string, $quote_style );
$string(string) (required)
The text which is to be decoded.
$quote_style(string|int)
Converts double quotes if set to ENT_COMPAT, both single and double if set to ENT_QUOTES or none if set to ENT_NOQUOTES. Also compatible with old _wp_specialchars() values; converting single quotes if set to 'single', double if set to 'double' or both if otherwise set. Default: ENT_NOQUOTES
Examples
0
#1 Replace HTML entities with familiar HTML characters
$string = <<<'TEXT'
ampersand - & / & / &
single quotes - ' / '
double quotation marks - " / " / "
more - > / >
less - < / <
TEXT;
echo wp_specialchars_decode( $string, ENT_QUOTES );
/* will output:
ampersand - & / & / &
single quotes - ' / '
double quotes - " / " / "
more - > / >
less - < / <
*/
Beware that this function does not decode all entities. For example, it does not decode – (–).