Michan Posted March 1, 2008 Share Posted March 1, 2008 Hi, I'm stuck with an array. How would I count duplicate results in array? [0] => red [1] => blue [2] => red [3] => blue [4] => red Is there a way I can easily count these results so it returns: [0] => red(3) [1] => blue(2) ..or something similar? Thanks in advance! Link to comment https://forums.phpfreaks.com/topic/93804-counting-duplicate-results-in-an-array/ Share on other sites More sharing options...
trq Posted March 1, 2008 Share Posted March 1, 2008 Did you check the manual? array_count_values() does exactly what you want. Link to comment https://forums.phpfreaks.com/topic/93804-counting-duplicate-results-in-an-array/#findComment-480683 Share on other sites More sharing options...
Michan Posted March 1, 2008 Author Share Posted March 1, 2008 Did you check the manual? array_count_values() does exactly what you want. Thanks! I read the manual but couldn't find this for the life of me. You've saved me a whole lot of time! Link to comment https://forums.phpfreaks.com/topic/93804-counting-duplicate-results-in-an-array/#findComment-480687 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.