01-13-2010, 06:37 PM
|
#1 (permalink)
|
|
The Acquainted
Join Date: Feb 2008
Posts: 107
Thanks: 3
|
Crop Content
Hello, this snippet crops the content and puts "..." to the end. My question is, how can I get the rest of the content ?
PHP Code:
<?
$str = "Yeah, but on my website, before I realized that converting quotes, etc, to entities was a bad idea, I already had a lot of stuff put into a database...Also, symbols like show up as question marks... and I don't really know how to fix that. In my four years of HTML experience, and two years of PHP experience, I've never been able to get character encoding to do what I want it to.";
$chars = "150";
function shortText($str, $chars)
{
if (strlen($str) > $chars)
{
$str = substr($str, 0, $chars);
$str = $str . "...";
return $str;
}
else
{
return $str;
}
}
echo shortText($str, $chars);
?>
|
|
|