jeeva Posted March 5, 2007 Share Posted March 5, 2007 hi frnds, can i get count of a paricular value in an array? for example we have a array like $array=array(a,a,a,b,c,a,b,c,a,c); now i want count of 'a'. Result has to come as 5 can i get like this? Quote Link to comment Share on other sites More sharing options...
monk.e.boy Posted March 5, 2007 Share Posted March 5, 2007 $array=array('a','a','a','b','c','a','b','c','a','c'); $tmp = array_count_values($array) print $tmp['a']; monk.e.boy Quote Link to comment Share on other sites More sharing options...
monk.e.boy Posted March 5, 2007 Share Posted March 5, 2007 $array=array('a','a','a','b','c','a','b','c','a','c'); $tmp = array_count_values($array); echo $tmp['a']; ooops, missed a ; monk.e.boy Quote Link to comment Share on other sites More sharing options...
jeeva Posted March 5, 2007 Author Share Posted March 5, 2007 its working...........thanks Quote Link to comment 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.