Sorting an Associative Array by Column Value
Given an array of associative arrays, the task is to sort the elements based on a specific column value.例如,考虑以下数组:
目标是按“价格”列对$库存进行排序,导致:$inventory = array( array("type" => "fruit", "price" => 3.50), array("type" => "milk", "price" => 2.90), array("type" => "pork", "price" => 5.43), );这是一个示例:
= $ row ['price']; } array_multisort($ price,sort_desc,$ neventory);
通过排序$ price Array,我们间接排序$库存,因为它们共享相同的键。免责声明: 提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请说明详细缘由并提供版权或权益证明然后发到邮箱:[email protected] 我们会第一时间内为您处理。
Copyright© 2022 湘ICP备2022001581号-3