Note that there are some explanatory texts on larger screens.

plurals
  1. POstr_word_count() without HTML
    primarykey
    data
    text
    <p>I'm using <code>str_word_count()</code> to calculate the number of words in a content from <code>CKEditor</code>. the content I get from the CKEditior is an HTML content, and I need to calculate the word count. in MS words I get the word count 328. On the other hand in html tags I get from my content after using <code>str_word_count()</code> a 362 words. Is there any way to remove any HTML tags from a php string variable? I tried to use <code>strip_tags()</code>, and it gave me 336. is there any way to get the exact word count in PHP ? thank you in advance.</p> <p>for example this essay entered by a user like this.</p> <blockquote> <p>Mixed School or Unisex School</p> <p>Have you ever think about the impact of mixed schools for students? Most of the schools in the U.S are mixed gender, which mean girls and boys are studying with each other in the same classroom. Some parents wonder about the influences of their child’s in the school either in mixed school or in unisex ones. These influences are not about the education only, the influences about their personality, behavior with the opposite sex and finally their education. In my opinion, I think the unisex schools for teenager’s students are much better than mixed schools, and this conclusion based in many reasons.</p> </blockquote> <p>and in the MS word the word count is: <code>107</code></p> <p>in php </p> <blockquote> <p><code>&amp;nbsp;</code></p> <p>Mixed School or Unisex School</p> <p><code>&amp;nbsp;</code></p> <p>Have you ever think about the impact of mixed schools for students? Most of the schools in the U.S are mixed gender, which mean girls and boys are studying with each other in the same classroom. Some parents wonder about the influences of their child&rsquo;s in the school either in mixed school or in unisex ones. These influences are not about the education only, the influences about their personality, behavior with the opposite sex and finally their education. In my opinion, I think the unisex schools for teenager&rsquo;s students are much better than mixed schools, and this conclusion based in many reasons.</p> </blockquote> <p>and the result: <code>114</code></p> <p>I'm calculating an extra 7 words for one paragraph essay.</p> <h2>edit</h2> <p>after using</p> <pre><code> $text = strip_tags($this-&gt;orginal_content); $text = str_replace('&amp;nbsp;',"",$text); $this-&gt;orginal_content_count = str_word_count($text); </code></pre> <p>the result: <code>112</code></p> <p>I've found 3 spaces </p> <pre><code> Mixed School or Unisex School Have you ever think about the impact of mixed schools for students? Most of the schools in the U.S are mixed gender, which mean girls and boys are studying with each other in the same classroom. Some parents wonder about the influences of their child’s in the school either in mixed school or in unisex ones. These influences are not about the education only, the influences about their personality, behavior with the opposite sex and finally their education. In my opinion, I think the unisex schools for teenager’s students are much better than mixed schools, and this conclusion based in many reasons. </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload