note 59360 deleted from function.nl2br by googleguy
| From: | googleguy@php.net | Date: | Thu, 13 Jun 2013 11:02:58 +0000 |
| Subject: | note 59360 deleted from function.nl2br by googleguy | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-195152@lists.php.net to get a copy of this message | ||
Note Submitter: silya at rfvnu dot lg dot ua
----
Trouble was with file function when long tags where broken by \r\n and function strip_tags worked
not correctly with every element of array. This step prepare string from file for using function
file and then strip_tags. (For example, html file generated by M$ Word)
<?php
$str = file_get_contents($filename);
$str = str_replace("\r\n", "\n", $str);
$opentag = 0;
$nl = 0;
for($i = 0; $i < strlen($str); $i++)
{
if($opentag == 1 && $str[$i] == "\n")
{
$str[$i] = ' ';
continue;
}
if($str[$i] == '<')
$opentag = 1;
elseif($str[$i] == '>')
$opentag = 0;
else ;
}
?>