I have this string:
$array= 'orange, fruit, apple juice'
I want to count the single-word substrings in the string (orange/fruit)
I have tried
//Explode string at commas
$explode_tags = explode(",", $array);
//Check if space exists in substrings
foreach ($explode_tags as $explode_tag) {
if (strstr(trim($explode_tag), ' ') == false) {
...
}
}
Now I can’t figure out how to count the substrings only when the above IF statement comes false.
How about: