Good day.
Code:
array(4) {
[0]=> array(1) {
[0]=> array(3) {
[0]=> string(11) "art_7880" [1]=> string(1) "1" [2]=> int(2950)
}
[1]=> array(3) {
[0]=> string(8) "art_7880" [1]=> string(1) "1" [2]=> int(2955)
}
[2]=> array(3) {
[0]=> string(8) "art_7880" [1]=> string(1) "1" [2]=> int(1335)
}
[3]=> array(3) {
[0]=> string(8) "art_7883" [1]=> string(1) "1" [2]=> int(4335)
}
}
I get array unique elements:
我得到数组独特的元素:
$arr_uniq = array();
foreach ($all_array as $keys => $elms ) {
if(!in_array($elms[0], $arr_uniq)) {
$arr_uniq[] = $elms[0];
}
}
Tell me pleasse how to get a count each unique element in the general array?
告诉我如何计算一般数组中每个独特元素的数量?
result should been next:
结果应该是下一个:
art_7880 - 3
art_7880 - 3
art_7883 - 1
art_7883 - 1
2 个解决方案
#1
4
Assuming $all_array
is subarray of your main array in your var_dump
snipett, the general idea is
假设$ all_array是var_dump snipett中主数组的子数组,一般的想法是
$result = array();
foreach ($all_array as $elms)
$result[$elms[0]]++;
#2
0
array_count_values()
http://php.net/array_count_values
You should be able to easily apply this function.
您应该能够轻松应用此功能。
#1
4
Assuming $all_array
is subarray of your main array in your var_dump
snipett, the general idea is
假设$ all_array是var_dump snipett中主数组的子数组,一般的想法是
$result = array();
foreach ($all_array as $elms)
$result[$elms[0]]++;
#2
0
array_count_values()
http://php.net/array_count_values
You should be able to easily apply this function.
您应该能够轻松应用此功能。