5
I have a certain phrase declared in a variable. See:
$bacco = "Você tem que abrir seu coração pro SQL e pedir o que realmente quer.";
I can verify if there is a certain word inside the sentence using strpos, in this way:
if (strpos($bacco, 'que') !== false) {
echo 'true';
}
How can I check the number of times the word "that" repeats in this sentence?
str_split
with the desired word preceded and followed by a space, occurrences = array size - 1.– OnoSendai
Should return 2 just right? the
quer
whether or not to count?– rray
@rray why the word should be preceded/followed by a space ('which ').
– OnoSendai
Related: How to return most common words from a text with PHP? / Find occurrences of a word
– Guilherme Nascimento
Sorry @rray didn’t see the question.
quer
cannot enter the list.– viana