RE: [PHP] trikky string limit question
| From: | daniel | Date: | Fri, 14 Mar 2003 04:17:02 +0000 |
| Subject: | RE: [PHP] trikky string limit question | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-139661@lists.php.net to get a copy of this message | ||
never mind i worked it out
function create_caption($content,$max_length,$primaryID,$ID) {
if (strlen($content) > $max_length) {
$paragraph_i=".";
$position=strpos($content,$paragraph_i);
if (is_integer($position)) {
$preview=substr($content,0,$position);
$preview.="... [ <a
href=\"".$GLOBAL['PHP_SELF']."?".$primaryID."=".$ID."\">
More </a>]";
return $preview;
}
} else {
return $content;
}
}
explodes and splits were not getting the "." properly
>===== Original Message From daniel <daniel@electroteque.org> =====
>hi there , i am trying to show news content , the page may get pretty huge if
>they all show on the same page , i have been considering a caption of 255
>chars max , i would like to know if i could prob limit the front to 255 chars
>and if its between a word somehow show it till the last . probably meaning
the
>end of the sentence ? this could be a better option then show a more link for
>it ??
>
>
>
>--
>PHP General Mailing List (http://www.php.net/)
>To unsubscribe, visit: http://www.php.net/unsub.php