发布时间:2020-09-17
PHP 二维关联数组根据其中一个字段排序,
PHP 中二维关联数组如何根据其中一个字段进行排序,下面的代码将二维关联数组 $array 根据 $orderby 字段进行排序:
function wpjam_array_multisort($array, $orderby, $order = SORT_ASC, $sort_flags = SORT_NUMERIC){
$refer = array();
foreach ($array as $key => $value) {
$refer[$key] = $value[$orderby];
}
array_multisort($refer, $order, $sort_flags, $array);
return $array;
}
本站推荐使用的主机:,国外主机建议使用。
<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script> <script> (adsbygoogle = window.adsbygoogle || []).push({}); </script>
全站搜索