note 37799 modified in function.htmlentities by danbrown

From: Date: Sun, 17 May 2009 17:09:26 +0000
Subject: note 37799 modified in function.htmlentities by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-154948@lists.php.net to get a copy of this message
If you are looking for a htmlentities inverse : <?php $table = array_flip(get_html_translation_table(HTML_ENTITIES)); $plaintext = strtr($html, $table); ?> Here is a full example to extract plaintext from a SIMPLE html page (not table, etc...) <?php $file_content = file_get_contents($htmlfile); $file_content = strip_tags($file_content, '<br>'); $file_content = preg_replace('/<br( )?(\/)?>/i', "\n", $file_content); $file_content = wordwrap($file_content); $table = array_flip(get_html_translation_table(HTML_ENTITIES)); $file_content = strtr($file_content, $table); ?> --was-- If you are looking for a htmlentities inverse : <? $table = array_flip(get_html_translation_table(HTML_ENTITIES)); $plaintext = strtr($html, $table); ?> Here is a full example to extract plaintext from a SIMPLE html page (not table, etc...) <? $file_content = file_get_contents($htmlfile); $file_content = strip_tags($file_content, '<br>'); $file_content = preg_replace('/<br( )?(\/)?>/i', "\n", $file_content); $file_content = wordwrap($file_content); $table = array_flip(get_html_translation_table(HTML_ENTITIES)); $file_content = strtr($file_content, $table); ?> http://php.net/manual/en/function.htmlentities.php

« previous php.notes (#154948) next »