Counting unique elements in an array

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
Coocoran
Forum Newbie
Posts: 1
Joined: Sun Jan 30, 2005 2:13 am

Counting unique elements in an array

Post by Coocoran »

How do I count the unique elements in an array? eg.

Code: Select all

var_dump: array(3) { ї0]=> array(1) { ї0]=> int(2) } ї1]=> array(1) { ї0]=> int(2) } ї2]=> array(1) { ї0]=> int(3) } }
The values here are (2, 2, 3) - two unique elements. How do I count these to return a value of '2'?

Thanks!

Coocoran
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Post Reply