joyser Posted April 18, 2009 Share Posted April 18, 2009 ok, lets says i have an array that looks like this: {1,3,2,3,5,1,2,3,1,2,3,1,5} how do i find out how many different things are in that variable..in this case the anser would be "4" because there are four different things in it.... Link to comment https://forums.phpfreaks.com/topic/154620-how-do-i-count-how-many-different-things-are-in-an-array/ Share on other sites More sharing options...
JasonLewis Posted April 18, 2009 Share Posted April 18, 2009 Something like this: $array = array(1,1,3,3,3,4,4,5,5,5,5); echo count(array_unique($array)); Link to comment https://forums.phpfreaks.com/topic/154620-how-do-i-count-how-many-different-things-are-in-an-array/#findComment-813037 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.