我的代码是:$dataBerita = array( 'Babakan' => array(5), 'Babakan Pasar' => array(30), 'Bantar Jati' => array(70), 'Baranang Siang' => array(50), 'Batutulis' => array(40), 'Bojongkerta' => array(25), 'Bondongan' => array(90), 'Ciampea' => array(5), 'Cibadak' => array(2), 'Cilubang' => array(6));array_multisort($dataBerita, SORT_DESC);foreach ($dataBerita as $key => $value) { echo $value.", ";}我想显示10个数据数组中最大的5个数据数组,如下所示:90,70,50,40,30,
2 回答
慕的地8271018
TA贡献1796条经验 获得超4个赞
更改foreach为
foreach (array_slice($dataBerita,0, 5) as $key => $value) {
echo $dataBerita[$key][0].',';
}
- 2 回答
- 0 关注
- 111 浏览
添加回答
举报
0/150
提交
取消