11.11. Converting HTML to ASCII11.11.2. SolutionIf you have access to an external program that formats HTML as ASCII, such as lynx, call it like so: $file = escapeshellarg($file); $ascii = `lynx -dump $file`; 11.11.3. DiscussionIf you can't use an external formatter, the pc_html2ascii( ) function shown in Example 11-4 handles a reasonable subset of HTML (no tables or frames, though). Example 11-4. pc_html2ascii( )
11.11.4. See AlsoRecipe 9.9 for more on get_html_translation_table(); documentation on preg_replace( ) at http://www.php.net/preg-replace, get_html_translation_table( ) at http://www.php.net/get-html-translation-table, and strip_tags( ) at http://www.php.net/strip-tags.
Copyright © 2003 O'Reilly & Associates. All rights reserved. |
|