PHP check if a word consists of only three repeated characters : I retrieve results from a MySQL database, basically just a list of words. Occasionally a word will consist of only three repeated characters. How do I detect these words and strip off the two additional characters?

My best bet is using strlen to find three letter words, then explode and compare, then substr to strip off the extra characters, but that seems cumbersome. Is there an easy way?

    Sample data:
    house, dog, tree, aaa, cat, computer, sss, pink

    Expected output:
    house, dog, tree, a, cat, computer, s, pink

Help appreciated!