How to find out how many similar digit.

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
stimson
Forum Newbie
Posts: 2
Joined: Sun Sep 13, 2009 5:31 am

How to find out how many similar digit.

Post by stimson »

Hello,

i need to find out how many similar digit that given.

Example given digit: 5666 (must echo : 3 similar digit)
Example given digit: 8866 (must echo : 2 pair of similar digit)
Example given digit: 2336 (must echo : 1 pair of similar digit)
Example given digit: 3576 (must echo : 0 pair of similar digit)

what function i can use to get the echo?
User avatar
Darhazer
DevNet Resident
Posts: 1011
Joined: Thu May 14, 2009 3:00 pm
Location: HellCity, Bulgaria

Re: How to find out how many similar digit.

Post by Darhazer »

First split it to an array, then use array_count_values
stimson
Forum Newbie
Posts: 2
Joined: Sun Sep 13, 2009 5:31 am

Re: How to find out how many similar digit.

Post by stimson »

Thanks alot Darhazer!
Post Reply