title: Count all word including numbers in a php string
body: <p>To count words in a php string usually we can use str_word_count but I think not always a good solution</p>
  
  <h3>good example:</h3>
  
  <pre><code>$var ="Hello world!";
  echo str_word_count($str);
  print_r(str_word_count($str, 1));
  </code></pre>
  
  <p>-->output</p>
  
  <pre><code>   2
     Array ( [0] =&gt; Hello [1] =&gt; world ) 
  </code></pre>
  
  <h3>bad example:</h3>
  
  <pre><code>$var ="The example number 2 is a bad example it will not 
  count numbers  and punctuations !!";
  </code></pre>
  
  <p>-->output:</p>
  
  <pre><code>  14
    Array ( [0] =&gt; The [1] =&gt; example [2] =&gt; number [3] =&gt; is [4] =&gt; a
    [5] =&gt; bad [6] =&gt; example [7] =&gt; it [8] =&gt; will [9] =&gt; not 
    [10] =&gt; count [11] =&gt; numbers [12] =&gt; and [13] =&gt; punctuations ) 
  </code></pre>
  
  <p>Is there a good predefined function to do this properly or do I have to use preg_match() ?</p>