RE: [PHP] Truncate words in multiple paragraphs

2006-02-03 Thread php-mail
Nuts Missed the need to preserve line breaks Sorry Dan -Original Message- From: tedd [mailto:[EMAIL PROTECTED] Sent: 03 February 2006 23:06 To: php-general@lists.php.net Subject: Re: [PHP] Truncate words in multiple paragraphs >Hi :) > >I am using the following function (tha

Re: [PHP] Truncate words in multiple paragraphs

2006-02-03 Thread tedd
Hi :) I am using the following function (that I found in the user comments on php.net manual) for trimming the number of words accepted via a form field // Truncation is by word limit, not character limit. So if you limit // to 255, then it will cut off a text item to 255 words, not 255 chara

RE: [PHP] Truncate words in multiple paragraphs

2006-02-03 Thread php-mail
To: Verdon Vaillancourt Cc: [EMAIL PROTECTED]; John Meyer; PHP eMail List Subject: Re: [PHP] Truncate words in multiple paragraphs Just do this: $string = str_replace("\n", "", $string); $string = trim_text($string); $string = str_replace("", "\n", $string);

Re: [PHP] Truncate words in multiple paragraphs

2006-02-03 Thread Verdon Vaillancourt
On 3-Feb-06, at 4:19 PM, Richard Lynch wrote: On Fri, February 3, 2006 10:54 am, Verdon Vaillancourt wrote: I am using the following function (that I found in the user comments on php.net manual) for trimming the number of words accepted via a form field // Truncation is by word limit, not ch

Re: [PHP] Truncate words in multiple paragraphs

2006-02-03 Thread Richard Lynch
Just do this: $string = str_replace("\n", "", $string); $string = trim_text($string); $string = str_replace("", "\n", $string); Actually could be any sequence of non-whitespace characters unlikely to be in the text in the first place. On Fri, February 3, 2006 3:29 pm, Verdon Vaillancourt wrote

Re: [PHP] Truncate words in multiple paragraphs

2006-02-03 Thread Verdon Vaillancourt
Hi Richard, I quickly realized this and fooled with a few variations. Also have to take into account that the or the get counted as 1 or 2 words respectively, and so the trim can end up in the wrong place. I've tried fiddling with counting the number of br's in the string and adding that to

Re: [PHP] Truncate words in multiple paragraphs

2006-02-03 Thread Richard Lynch
This would work if you replace the with -- Otherwise, it's too likely to break up "" in the trim_text function and then you end up with: "start of string ... almost 255 words, blah blah blah -BEGIN PGP SIGNED MESSAGE- > Hash: SHA1 > > Verdon Vaillancourt wrote: >> Hi :) >> >> I am usin

Re: [PHP] Truncate words in multiple paragraphs

2006-02-03 Thread Richard Lynch
On Fri, February 3, 2006 10:54 am, Verdon Vaillancourt wrote: > I am using the following function (that I found in the user comments > on > php.net manual) for trimming the number of words accepted via a form > field > > // Truncation is by word limit, not character limit. So if you limit > // to 2

Re: [PHP] Truncate words in multiple paragraphs

2006-02-03 Thread Verdon Vaillancourt
On 3-Feb-06, at 12:25 PM, John Meyer wrote: -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Verdon Vaillancourt wrote: Hi :) I am using the following function (that I found in the user comments on php.net manual) for trimming the number of words accepted via a form field // Truncation is by

Re: [PHP] Truncate words in multiple paragraphs

2006-02-03 Thread John Meyer
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Verdon Vaillancourt wrote: > Hi :) > > I am using the following function (that I found in the user comments on > php.net manual) for trimming the number of words accepted via a form field > > // Truncation is by word limit, not character limit. So if