whats happening: its counting words & special chars (except +) from textarea as words. which is perfectly fine.
Whats going wrong: If I copy paste a large chunk of words - e.g. 900 , i dont get a output.. if i add one character at a time, it calculates..but a large no of words & it just stops!!!
textarea code:
<textarea rows="10" cols="40" name="noofwords" onKeyUp="calculate_words(this.value);"></textarea>
PHP code where calculation is happening:
if(!empty($totalwords))
{
//$wordlength = strlen($totalwords);
$string = trim(preg_replace(array('/\s{2,}/', '/[\t\n]/')," ",$totalwords)); // \t \n n " " is replaced by " "
$word_array = explode(" ", $string);
$num = count($word_array);
echo "3"."|".$num;
}
dont think variables are wrong.. there is a js file in between where $totalwords = noofwords entered in textarea. Only problem: its SLOW!!!