PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
kevrelland
Forum Commoner
Posts: 73 Joined: Mon Jan 08, 2007 7:41 am
Post
by kevrelland » Thu Jun 10, 2010 5:46 am
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
dejvos
Forum Contributor
Posts: 122 Joined: Tue Mar 10, 2009 8:40 am
Post
by dejvos » Thu Jun 10, 2010 5:55 am
What about this:
Code: Select all
<?php
$x = strip_tags($row_archive['archive_content'], '<a>');
echo TrimByLength($x, 200, false);
?>
kevrelland
Forum Commoner
Posts: 73 Joined: Mon Jan 08, 2007 7:41 am
Post
by kevrelland » Thu Jun 10, 2010 5:58 am
Thanks, perfect.
i'm stuck at work without my book, and was having a brain melt down and just couldn't think
pickle
Briney Mod
Posts: 6445 Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:
Post
by pickle » Thu Jun 10, 2010 9:55 am
I'm not sure what your TrimByLength() function does, but you may be able to use
substr() instead.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
AbraCadaver
DevNet Master
Posts: 2572 Joined: Mon Feb 24, 2003 10:12 am
Location: The Republic of Texas
Contact:
Post
by AbraCadaver » Thu Jun 10, 2010 10:20 am
Code: Select all
<p><?php echo TrimByLength(strip_tags($row_archive['archive_content']), 200, false); ?></p>
mysql_function(): WARNING : This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.