百度 | 神马 | 搜狗 | 技术文档 | 学习资料分享 - 记录帝国CMS及运维技术的点点滴滴
你的位置:首页 > 实用IT技术 » 正文

【Wordpress相关】PHP 二维关联数组根据其中一个字段排序

发布时间:2020-09-17

作品分类:Wordpress相关  数组  字段  关联  数组  其中一个  字段  关联  排序

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>

Top