Archived Boards and Threads... > Parham's PHP Tutorials
Help with article preview
(1/1)
woden:
I want to snatch about 200 characters from mysql table row "content' to use as a preview for articles.
This code (below) is working ok but if there is html code for images I end up with a very short description.
How can I make it count the characters AFTER the html tags are stripped, instead of before?
I know there has to be a way, anything is possible with php :D
--- Quote ---$pdescription = trim(strip_tags((substr($row['content'],0,200)),'<b>,<br>'));
echo "$pdescription...";
--- End quote ---
Spaceman-Spiff:
A bit late answer, but...
$pdescription = substr(strip_tags(trim($row['content']), '<b><br>'), 0, 200);
or you can make it longer, but easier to read:
$pdescription = trim($row['content']);
$pdescription = strip_tags($pdescription, '<b><br>');
$pdescription = substr($pdescription, 0, 200);
Navigation
[0] Message Index
Go to full version