Welcome Guest, Not a member yet? Register   Sign In
how to find and count the words in a string?
#11

[eluser]basty_dread[/eluser]
[quote author="basty_dread" date="1258392322"]
// the only words that will appear in the design view of ckeditor is this:

this is my page and the page is the only page that is nice

// what i want is to count only the words in design view.

is it possible?

[/quote]


I mean count.. count the words... disregarding the html tags..

How many words we have in here? 14 words. that is the word count.

no more searching.
#12

[eluser]saidai jagan[/eluser]
Use this,
Code:
$search = '@<[\/\!]*?[^<>]*?&gt;@si'; // Strip the HTML tags
$replace=''; // replacing with none
$strings='<h1 style="text-align: center;">
    <span style="font-family: comic sans ms,cursive;">this is my page and the page is the only page that is nice<br />
    </span></h1>';
$non_html_text = preg_replace($search, $replace, $strings); // here we are removing the html chars
// here it will retun this is my page and the page is the only page that is nice
echo '<br>'.str_word_count($non_html_text); // it will echo 14
#13

[eluser]basty_dread[/eluser]
thank you saidai jagan,,,
you are the best ....
thanks..




Theme © iAndrew 2016 - Forum software by © MyBB