Is there a function that counts the number of words in a string?
I checked through the manual and archives using 'word count', and found
nothing. I suppose it is possible to generate code that will accomplish this,
using 'space' as the delimiting separator. But before I re-invent the wheel .
Andre:
On Mon, Jun 24, 2002 at 05:29:16PM -0400, Andre Dubuc wrote:
Is there a function that counts the number of words in a string?
I don't recall there being one. But, you could do this:
$array = preg_split('/\s+/', $string);
echo count($array);
Enjoy,
--Dan
--
PHP
Thanks Dan,
Does the job neatly!
Regards,
Andre
On Monday 24 June 2002 06:01 pm, you wrote:
Andre:
On Mon, Jun 24, 2002 at 05:29:16PM -0400, Andre Dubuc wrote:
Is there a function that counts the number of words in a string?
I don't recall there being one. But, you could do this:
3 matches
Mail list logo