|
|
Convert HTML to Text with PHP-4
Overview
This example is part of the project
titled HTML Parser for PHP-4.
It's a class named Html2Text which
converts HTML to ASCII text, while attempting to
preserve page formatting.
Requirements
Tested with PHP 4.0.4. It should work with PHP 4.0.3+.
Download
The latest version is available at SourceForge's
download area for this project.
Limitations
Perhaps the most relevant limitations of the latest
version of this simple tool are that it ignores
tables and that it does not center.
Author
The HTML Parser for PHP-4 and this example were written by
Jose Solorzano
of Starnetsys, LLC. (If you need a website or program
developed professionally, affordably, and on time, be sure to contact
starnetsys.com.)
Usage Tips
You only need to copy src/htmlparser.inc
and src/html2text.inc to a location in your
codebase where you'd like to be able to include them.
The PHP file that uses this conversion tool could
look like this:
<?
include ("html2text.inc");
$htmlText = "... HTML text here ...";
$asciiText = new Html2Text ($htmlText, 15); // 15 columns maximum
$text = $htmlToText->convert();
echo "Converted to: " . $text;
?>
Feedback
- For feature requests, please use SourceForge's
Feature Request Tracker.
- To report a bug, use SourceForge's
Bug Tracking System.
- For questions, use SourceForge's
Forums for this project.
- If you want to be added to this project as a developer,
send me a sample or a sketch of the
code you plan to add.
|