Lot of answers that use substr_count checks if the result is >0
. But since the if
statement considers zero the same as false, you can avoid that check and write directly:
if (substr_count($a, 'are')) {
To check if not present, add the !
operator:
if (!substr_count($a, 'are')) {