【发布时间】:2019-03-27 15:54:07
【问题描述】:
我想从数组中回显最常见的数字。我有一个数组,我想将前一个键与我的数组的当前键进行比较。我该怎么做?
我做了两个 foreach 循环:
$mostCommon = 0;
foreach ($_SESSION['array'] as $key => $value) {
foreach ($_SESSION['array'] as $key2 => $value2){
$key++;
}
if(current key is higher than previous key){
$mostCommon = $value;
}
}
这就是我不想这样做的方式。
【问题讨论】:
-
我没有看到
common number和比较键之间的联系。