How to use php str_word_count to count words in a textarea

Solution:
Using it is really easy. For example if your textarea is named "mytextarea
" and you sent the form via POST (<form method="POST">
), your textarea data will be in$_POST['mytextarea']
Then counting the words :
$count = str_word_count($_POST['mytextarea']);
Then you just have to use the $count variable to do whatever you want.
Answer
Solution:
$var =textareaObject.value ; //Store textarea text in $var
print_r(str_word_count($var));
Answer
Solution:
How about just use$words= str_word_count($_POST['clientdetails']);
then, probably just do a simple maths like
$fee = $words * 0.50;
0.50 is the amount of money you are going to charge
then, something like:
<?php echo 'we are going to charge you '.$fee.' for these words'; ?>
Share solution ↓
Additional Information:
Link To Answer People are also looking for solutions of the problem: you must enable the openssl extension in your php.ini to load information from https://repo.packagist.org
Didn't find the answer?
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Similar questions
Find the answer in similar questions on our website.
Write quick answer
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.