Jump to content

[SOLVED] Count Distinct Values in Array


musclehead

Recommended Posts

Hello,

 

I have a simple, one-dimensional array:

 

$myArray = array('apple','apple','orange','apple','banana','orange','orange','orange','banana','apple');

 

I'm looking for an easy way/built-in function to count the distinct values in that array, so to return 4 for apples.

 

Any ideas?

 

Thanks.

Link to comment
https://forums.phpfreaks.com/topic/88388-solved-count-distinct-values-in-array/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.