If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

Enjoy an ad free experience by logging in. Not a member yet? Register.

Use strtolower to make the comparisons case insensitive. Split the string and use array_count_values to get an array with the character as the array key and the number of occurrences as the value. Then you just need to remove the single occurrences (value = 1, you could use array_diff) and count the remainder.

Yes, the first line in that function should be $str = strtolower($str);, I didn't notice you said case insensitive. It should work with that though. I guess this is what happens when you don't go to bed when you should ;P

I also didn't notice you only want it for letters as well. This could be solved with a simple regular expression. Result:

I see what he meant now, he wants characters that have duplicates in the string (case insensitive).
The function I created simply returned bow many different letters there were (case insensitive) rather than that.

That being said I should probably not give advice when I haven't slept in a while, I can't read things straight sometimes.

I see what he meant now, he wants characters that have duplicates in the string (case insensitive).
The function I created simply returned bow many different letters there were (case insensitive) rather than that.

That being said I should probably not give advice when I haven't slept in a while, I can't read things straight sometimes.

So based on what you originally posted modified to meet the requirements you originally missed: