检查数组PHP多少次特定的值 [英] Check how many times specific value in array PHP
本文介绍了检查数组PHP多少次特定的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个数组名为$ UID。我怎么能检查值12有多少次是在我的$ UID阵列?
I have an array named $uid. How can I check to see how many times the value "12" is in my $uid array?
推荐答案
的几种方法。
$cnt = count(array_filter($uid,create_function('$a','return $a==12;')));
或
$tmp = array_count_values($uid);
$cnt = $tmp[12];
或任何数目的其他方法。
or any number of other methods.
这篇关于检查数组PHP多少次特定的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文