EHamilton
Nov 12th 2006, 10:13 pm
What's up? I'm pretty noobish at php and need some help with implementing this code correctly without causing errors. I have a line that reads...
echo " <p class=\"desc\">".$srow['discription']."</p>\n";
I need it to basically read this...
echo "
<p class=\"desc\">
<?
function truncateString($str, $max, $rep = '...') {
if(strlen($str) > $max) {
$leave = $max - strlen($rep);
return substr_replace($str, $rep, $leave);
} else {
return $str;
}
}
print truncateString(".$srow['discription'].", 25);
?>
</p>\n";
What I'm trying to do is set the string to read a certain amount of characters. I know I'm getting an error probably because I'm putting php inside of echo lmfao. Any help is appreciated :o
echo " <p class=\"desc\">".$srow['discription']."</p>\n";
I need it to basically read this...
echo "
<p class=\"desc\">
<?
function truncateString($str, $max, $rep = '...') {
if(strlen($str) > $max) {
$leave = $max - strlen($rep);
return substr_replace($str, $rep, $leave);
} else {
return $str;
}
}
print truncateString(".$srow['discription'].", 25);
?>
</p>\n";
What I'm trying to do is set the string to read a certain amount of characters. I know I'm getting an error probably because I'm putting php inside of echo lmfao. Any help is appreciated :o