sanlike Posted December 8, 2014 Share Posted December 8, 2014 i HAVE FOLLOWING VALUES IN FEED TABLE a1a a1b a1c a1d ...... 7 8 7 7 8 9 8 8 9 7 7 8 7 8 10 9 6 4 6 7 7 8 8 5 9 7 7 6 This in an array ( select a1a,a1b,a1c,a1d from feed where .....) 1) I want to know how many times each values has occured in the array ( eg: 7 occured 10 times, 8 occured 8 times) 2) How many 7's, 8's, 9's are there in a1a, howmany .....in a1b Number of times each values occured OVERALL in array as well as also under each head Please help Quote Link to comment https://forums.phpfreaks.com/topic/292971-count-number-of-times-a-value-occures-in-array/ Share on other sites More sharing options...
Psycho Posted December 8, 2014 Share Posted December 8, 2014 (edited) Start with this: http://php.net/manual/en/function.array-count-values.php Also, you state this is an array, but then have the comment select a1a,a1b,a1c,a1d from feed where ..... That seems to indicate this is from a DB query. If so, the solution is to add the logic in the query. Edited December 8, 2014 by Psycho Quote Link to comment https://forums.phpfreaks.com/topic/292971-count-number-of-times-a-value-occures-in-array/#findComment-1499026 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.