gpt4 book ai didi

php - 计数数组 DISTINCT 以上 1

转载 作者:行者123 更新时间:2023-11-29 18:42:28 26 4
gpt4 key购买 nike

仅当 customer_id 存在超过 1 时,我如何进行计数。

因为我只想计算数字是否存在超过 1 次。

 $customerOrder = $this->Order->find('all', array(
'conditions' => array(
'Order.customer_id >' => '0',
'Order.status' => 'Delivered'
)
));
$b = array_unique($customerOrder);
Echo Count(array_unique(array_diff_key($customerOrder, $b)));

至少我应该得到3:它应该给出大约 100 的结果。这是列表的一个小屏幕截图:enter image description here

最佳答案

这个方法怎么样?数组唯一、数组差异键和计数。

$a = array(1,2,3,3,3,4,1,1,3,2);
$b = array_unique($a);


Echo Count(array_unique(array_diff_key($a, $b)));

https://3v4l.org/La1mN

关于php - 计数数组 DISTINCT 以上 1,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44862858/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com