Re: PHP Tokenize a String by its length
Available news archives: comp.lang.tcl - comp.lang.python - comp.security.firewalls - sci.crypt - comp.lang.php - comp.lang.javascript
Google
 
Web news.hping.org


comp.lang.php archive

Re: PHP Tokenize a String by its length

From: Lüpher Cypher <lupher.cypher@verizon.net>
Date: Sat Dec 31 2005 - 11:12:21 CET

Mavenos wrote:
> Hi Web Masters,
>
> Just wondering wether you can help us to come up with some tokenize
> script.
>
> My problem is wanted to display a LONG content into a short para (by
> giving minimum letter lenght)
>
> I mean if I have a 2 page content - just I want to display only 4 lines
> having 200 letters then follows the content with "....." at the end of
> short pera.
>
> Can anybody help in this regards,
> Thanks in advance
>

How about

$maxLetters = 300;
$shortContent = substr($longContent,0,$maxLetters).
                 (strlen($longContent) > $maxLetters ? "..." : "");

luph
Received on Tue Jan 3 03:50:48 2006