NYCPHP Meetup

NYPHP.org

[nycphp-talk] strpos with space

Cassidy, Michael Michael_Cassidy at advancemags.com
Mon Jul 25 15:21:45 EDT 2005


How about displaying for the first 125 spaces; that should get you close to
250 words



From: Brian O'Connor <gatzby3jr at gmail.com>
Reply-To: NYPHP Talk <talk at lists.nyphp.org>
Date: Mon, 25 Jul 2005 15:15:24 -0400
To: NYPHP Talk <talk at lists.nyphp.org>
Subject: Re: [nycphp-talk] strpos with space

Same result, and I also tried replacing $words altogether with 250 just to
test that, and still the same result.

As a side note, the . str_word_count($text) is there for debugging purposes
and I didn't get around to taking it out.

On 7/25/05, CED < Consult at covenantedesign.com
<mailto:Consult at covenantedesign.com> > wrote:
> Try NOT setting the value of $words in the paramater.
>  
> try 
> <?
>  
> $words = 250 ;
>  
> function creatText($text, $words)
>     {       if(str_word_count($text) < $words) {
>         return $text;
>     } else {
>         return substr($text, 0, strpos($text, ' ', $words)) . ' ... [ <a
> href="link">full text</a> ]' . str_word_count($text);
>     }        
> }
>  
> ?>
>  
>  
>>  

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.nyphp.org/pipermail/talk/attachments/20050725/1ef0e5d7/attachment.html>


More information about the talk mailing list