gdfhghjdfghgfhf Posted December 25, 2009 Share Posted December 25, 2009 Well i'm looking to do something i usually could do easily using COUNT and GROUP BY if it was a sql query... But this time i'm working with an array... so i have an array that looks like this $array( "dog", "cat", "dog", "fish", "horse", "cat", ); First i want to group together the duplicate entries. And then, i want to list the number of times the item was found in the array with the above example, i would be expecting a result like this: $array( "dog (2 results)", "cat (2 results)", "fish (1 results)", "horse (1 results)", ); From what i have read on google i can group together the duplicate entry with array_unique() but i have no idea how i can list the number of times this item was found in the array thanks for helping me!! Link to comment https://forums.phpfreaks.com/topic/186329-group-by-in-arrays/ Share on other sites More sharing options...
PFMaBiSmAd Posted December 25, 2009 Share Posted December 25, 2009 http://us.php.net/manual/en/function.array-count-values.php Link to comment https://forums.phpfreaks.com/topic/186329-group-by-in-arrays/#findComment-983975 Share on other sites More sharing options...
gdfhghjdfghgfhf Posted December 25, 2009 Author Share Posted December 25, 2009 thanks Link to comment https://forums.phpfreaks.com/topic/186329-group-by-in-arrays/#findComment-983976 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.