how to get number of how much the string is common in a array

Hey I have an array with a bunch of data

I did a array_count_values , and now I've got something like this:

$bots = array_count_values($all_bots);
arsort($bots); 

Array ( ["abc"] => 9 ["xyz"] => 1 )

I just want to get the number. So just the 9.

Does someone can tell me how do I get just the number?


$bots = array_count_values($all_bots);
arsort($bots)
echo current($bots); 

After sorting you can get the first value with current() . However, I'd suggest forgoing the sort operation and using max instead:

$mostOccuring = max(array_count_values($all_bots));

This produces the same result a lot more efficiently. Obviously you won't get the string itself though ("abc").

链接地址: http://www.djcxy.com/p/10184.html

上一篇: 数组之间的差异()和[]

下一篇: 如何获取字符串在数组中常见的数量