Hello,
first of all: Excuse me for some bad English you might experience during the reading of this.
So I made this form with an textarea, people can write a comment in here but I wanted to create something that my function counts specific words in it and says:
Word 1: 12 times
Word 2: 3 times
etc
etc
Code of what I have so far (I'm still a beginner in PHP):
I just can't get it to work, each try I get different errors, I hope I am clear enough.
Thanks
first of all: Excuse me for some bad English you might experience during the reading of this.
So I made this form with an textarea, people can write a comment in here but I wanted to create something that my function counts specific words in it and says:
Word 1: 12 times
Word 2: 3 times
etc
etc
Code of what I have so far (I'm still a beginner in PHP):
Code:
$commentaar = trim($_POST['commentaar']);
function commenteva($commentaar)
{
global $commentaar;
$commentaar = nl2br($commentaar); //newlines
$positive = array("goed", "top", "beste"); //Positive words
$negative = array("slecht", "kut", "beter", "zuigt", "haat"); //Negative words
$plengte = strlen($positief);
$nlengte = strlen($negatief);
echo ("<br />Aantal positieve woorden: " . $plengte);
echo ("<br />Aantal negatieve woorden: " . $nlengte);
if($plengte > $nlengte)
{
echo("<br />Commentaar is positief");
}
elseif($nlengte > $plengte)
{
echo("<br />commentaar is negatief");
}
else
{
echo("<br />commentaar is neutraal");
}
}
Thanks
Comment