Substr + Text + HTML - Problem
| From: | Sascha Ragtschaa | Date: | Mon, 25 Feb 2002 14:05:53 +0000 |
| Subject: | Substr + Text + HTML - Problem | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-86086@lists.php.net to get a copy of this message | ||
Hi,
I still have one problem, which seems to be not solveable in a easy and
smooth way:
I have a text file like this:
$text="This is a html extended text<br>which needs to be cut after 100
chars<br>";
Than I do a substring to limit it to only 100 words (teaser-format):
$teaser_1=substr($text, 0, 100);
$teaser_2="...<a>[click here for more]</a>";
The Output of $teaser_1 will sometimes be like this:
"This is a html extended text<br>which needs to be cut after 100 chars<br"
The <br> is displayed as <br and not properly closed due to the limitation
of 100 chars, and therefore messes up my whole webpage! Is there a way to
let the function recognize, if the last part of the string is a unclosed
html tag?
Does anyone have a idea how to do it? Tried around a couple of things, but
nothing worked out yet...
Sascha Ragtschaa