Welcome Guest, Not a member yet? Register   Sign In
how to find and count the words in a string?
#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


Messages In This Thread
how to find and count the words in a string? - by El Forum - 11-16-2009, 02:46 AM
how to find and count the words in a string? - by El Forum - 11-16-2009, 02:59 AM
how to find and count the words in a string? - by El Forum - 11-16-2009, 03:00 AM
how to find and count the words in a string? - by El Forum - 11-16-2009, 03:07 AM
how to find and count the words in a string? - by El Forum - 11-16-2009, 03:38 AM
how to find and count the words in a string? - by El Forum - 11-16-2009, 03:59 AM
how to find and count the words in a string? - by El Forum - 11-16-2009, 04:01 AM
how to find and count the words in a string? - by El Forum - 11-16-2009, 05:25 AM
how to find and count the words in a string? - by El Forum - 11-16-2009, 05:41 AM
how to find and count the words in a string? - by El Forum - 11-16-2009, 05:44 AM
how to find and count the words in a string? - by El Forum - 11-16-2009, 07:39 PM
how to find and count the words in a string? - by El Forum - 11-17-2009, 03:18 AM
how to find and count the words in a string? - by El Forum - 11-17-2009, 04:14 AM



Theme © iAndrew 2016 - Forum software by © MyBB