PHP echo number of instances if specific word?
I have exploded an array and found the word “and” in it, and i want to echo the number of times it occurs.
anyone enlighten me to a simple solution?
——————
$content = “array that is exploded, its pretty long so i just used this for example text but should return 4 ‘and’s ”;
$and = “and”;
$words = explode(” ”, $content);
if (in_array($and, $words)) {
echo ”‘and’ occurs this many times”;
}
else {
echo “none”;
}
Observing members:
0
Composing members: 0
Composing members: 0