Convert HTML markup to readable text
Like PHP’s strip_tags but with some small improvements in HTML-to-text conversion that improves the readability of the text.
In 3.0.197+ inner content of script, style and object tags is now removed, rather than just the tags. To revert this behavior or to remove content of additional tags, see the clearTags
option.
Note that this method differs from the Sanitizer::markupToText()
method in that this method is newer,
more powerful and has more options. But the two methods differ in how they perform markup-to-text
conversion so you may want to review and try both to determine which one better suits your needs.
Usage
// basic usage
$string = $wireTextTools->markupToText(string $str);
// usage with all arguments
$string = $wireTextTools->markupToText(string $str, array $options = []);
Arguments
Name | Type(s) | Description |
---|---|---|
str | string | String to convert to text |
options (optional) | array |
|
Return value
string
See Also
WireTextTools methods and properties
API reference based on ProcessWire core version 3.0.236