Page 1 of 1

Trimming and stripping

Posted: Thu Jun 10, 2010 5:46 am
by kevrelland
Hi, i want to strip the tags from this database return as well as limit the number of characters returned.

Code: Select all

<p><?php echo strip_tags($row_archive['archive_content'], '<a>') ?></p>
I have got this and and it strips the tags perfectly but i have no idea on how to combine the trim with it

Code: Select all

<p><?php echo TrimByLength($row_archive['archive_content'], 200, false); ?></p>
Which trims the length beautifully
Can you guys help me out
Cheers
Kev

Re: Trimming and stripping

Posted: Thu Jun 10, 2010 5:55 am
by dejvos
What about this:

Code: Select all

<?php
$x = strip_tags($row_archive['archive_content'], '<a>');
echo TrimByLength($x, 200, false);
?>

Re: Trimming and stripping

Posted: Thu Jun 10, 2010 5:58 am
by kevrelland
Thanks, perfect.
i'm stuck at work without my book, and was having a brain melt down and just couldn't think

Re: Trimming and stripping

Posted: Thu Jun 10, 2010 9:55 am
by pickle
I'm not sure what your TrimByLength() function does, but you may be able to use substr() instead.

Re: Trimming and stripping

Posted: Thu Jun 10, 2010 10:20 am
by AbraCadaver

Code: Select all

<p><?php  echo TrimByLength(strip_tags($row_archive['archive_content']), 200, false); ?></p>