= 'a' && $string[$i] <= 'z') { $consonantCount++; } elseif ($string[$i] >= 0 && $string[$i] <= 9 && is_numeric($string[$i])) { $numberCount++; } } return 'total vowels - ' . $vowelCount . PHP_EOL . 'total consonant - ' . $consonantCount . PHP_EOL . 'total numeric number -' . $numberCount . PHP_EOL; } // example echo countVowelsConsonant('Hello World. 12345'); echo countVowelsConsonant('Count Vowels, Consonant and numeric number. 09876');