$sanitizer->unentities() method

Remove entity encoded characters from a string.

Wrapper for PHP's html_entity_decode() function that contains typical ProcessWire usage defaults.

The arguments used here are identical to those for PHP’s (except $flags can be boolean true):
html_entity_decode function.

For the $flags argument, specify boolean true if you want to perform a more comprehensive entity decode than what PHP does. That will make it convert all UTF-8 entities (including decimal and hex numbered entities), and it will remove any remaining entity sequences if the could not be converted, ensuring there are no entities possible in returned value.

Usage

// basic usage
$string = $sanitizer->unentities(string $str);

// usage with all arguments
$string = $sanitizer->unentities(string $str, $flags = 3, string $encoding = 'UTF-8');

Arguments

NameType(s)Description
strstring

String to remove entities from

flags (optional)int, bool

See PHP html_entity_decode function for flags, OR specify boolean true to convert all entities and remove any that cannot be converted (since 3.0.105).

encoding (optional)string

Encoding (default="UTF-8").

Return value

string

String with entities removed.

See Also


$sanitizer methods and properties

API reference based on ProcessWire core version 3.0.148

Twitter updates

  • Weekly update for Jan 10, 2020—front-end file uploads in LoginRegisterPro with InputfieldFrontendFile module: More
    10 January 2020
  • If you haven't seen it yet, be sure to check out this great infographic by @teppokoivula in ProcessWire Weekly #294— How ProcessWire professionals work—the results of our recent weekly polls summarised: weekly.pw/issue/294/#how…
    3 January 2020
  • Today we have a new master version released, 3.0.148! There are 25 new versions worth of upgrades, fixes and optimizations in this new master version, relative to the previous. In this post we take a closer look at what’s new, how to upgrade, & more— More
    3 January 2020

Latest news

  • ProcessWire Weekly #297
    In the 297th issue of ProcessWire Weekly we're going to check out the latest core updates (ProcessWire 3.0.149) and introduce a new third party module called StaticWire. Read on!
    Weekly.pw / 18 January 2020
  • ProcessWire 3.0.148 new master
    Today we have a new master version released, version 3.0.148! The last master version was 3.0.123, so there are 25 new versions worth of upgrades, fixes and optimizations in this new master version, relative to the previous. In this post we’ll take a closer look at what’s new, how to upgrade, and more.
    Blog / 3 January 2020
  • Subscribe to weekly ProcessWire news

“ProcessWire is like a breath of fresh air. So powerful yet simple to build with and customise, and web editors love it too.” —Margaret Chatwin, Web developer