To my great surprise, all the other answers are too zealous. Some of them convert a string to an array, replacing characters using regular expression, looping, and writing custom functions.
That is all there is to doing, two string functions:
$string='aaaba'; var_export(strlen(count_chars($string,3))>1?false:true); // false
These two functions ( count_chars() and strlen() ) were designed specifically for this purpose.
source share