PHP Classes
elePHPant
Icontem

What is the best PHP count words class?: Count the number of words in a string

Recommend this page to a friend!
  All requests RSS feed  >  What is the best PHP count words class?  >  Request new recommendation  >  A request is featured when there is no good recommended package on the site when it is posted. Featured requests  >  No recommendations No recommendations  

What is the best PHP count words class?

Edit

Picture of Omotayo Odupitan by Omotayo Odupitan - 5 days ago (2016-10-25)

Count the number of words in a string

This request is clear and relevant.
This request is not clear or is not relevant.

+2

I need to count the number of words in a string.

  • 1 Clarification request
  • 1. Picture of Oleg Zorin by Oleg Zorin - 4 days ago (2016-10-27) Reply

    Good day, Omotayo Odupitan.

    <code>

    <?php

    function wordsCounter($string) {

    $string = preg_replace('/[^[:alpha:]]+/', ' ', $string);
    

    return count(explode(' ', $string));
    

    }

    • 2. Picture of Omotayo Odupitan by Omotayo Odupitan - 3 days ago (2016-10-27) in reply to comment 1 by Oleg Zorin Comment

      Thank you Oleg Zorin.

      Much appreciated.

Ask clarification

1 Recommendation

Portable UTF-8: Manipulate UTF-8 text strings in pure PHP

This recommendation solves the problem.
This recommendation does not solve the problem.

+2

Picture of Manuel Lemos by Manuel Lemos Reputation 15990 - 1 hour ago (2016-10-31) Comment

If you need a package that works well with UTF-8 and does not depend on the PHP extensions avaliable on your system, that package can solve your problem of counting words.

  • 1 Comment
  • 1. Picture of Omotayo Odupitan by Omotayo Odupitan - 1 hour ago (2016-10-31) Reply

    Thanks Manuel.


Recommend package
: 
: