robquistnl / simplehtmltotext
A Simple PHP Class to transform HTML to Text
Installs: 104 070
Dependents: 0
Suggesters: 0
Security: 0
Stars: 9
Watchers: 0
Forks: 3
Open Issues: 5
Type:lib
pkg:composer/robquistnl/simplehtmltotext
Requires
- php: >=5.3.0
Requires (Dev)
- phpunit/phpunit: ^4.8
This package is auto-updated.
Last update: 2025-10-29 03:02:54 UTC
README
A simple PHP class for transforming HTML to plain text (e.g. for emails)
Installation
Install using composer (composer require robquistnl/simplehtmltotext).
Usage
$myHtml = '<b>This is HTML</b><h1>Header</h1><br/><br/>Newlines'; echo (new Parser())->parseString($myHtml);
Returns:
**This is HTML**
### Header ###
Newlines
Supported tags
Currently only a few basic tags are supported, and no CSS is checked.
brhrh1,h2,h3,h4,h5,h6table,tr,td,th(Very basic support)b,strong,u,i,emaSimple support;<a href="http://example.org">Click here</a>becomesClick here (http://example.org)imgSimple support;<img src="http://example.org/image.jpg">becomesand<img alt="title" src="http://example.org/image.jpg">becomes(title)ul,ol,li,dd,dt