The reverse of turning ASCII text into HTML is to convert HTML into ASCII. And to this end here is a little function that does this.
function html2ascii($s){ // convert links // convert p, br and hr tags // convert bold and italic tags // decode any entities // decode numbered entities // strip any remaining HTML tags // return the string return $s; }
To use this function just pass it a string. Here is an example of it at work.
$htmlString = '<p>This is some <strong>XHTML</strong> markup that <em>will</em> be<br />turned <a href="http://www.hashbangcode.com/" title="#! code">into</a> an ascii string</p>'; echo html2ascii($htmlString);
Produces the following output.
This is some *XHTML* markup that _will_ be turned into (http://www.hashbangcode.com/) an ascii string
0 comments:
Post a Comment