Home > Backend Development > PHP Tutorial > Array_multisort method to sort multi-dimensional arrays in php, arraymerge multi-dimensional array_PHP tutorial

Array_multisort method to sort multi-dimensional arrays in php, arraymerge multi-dimensional array_PHP tutorial

WBOY
Release: 2016-07-13 09:46:51
Original
1003 people have browsed it

The method of array_multisort in php to sort multi-dimensional arrays, arraymerge multi-dimensional array

The example of this article describes the method of array_multisort in php to sort multi-dimensional arrays. Share it with everyone for your reference. The specific implementation method is as follows:

function sort_array($array, $keyid, $order='asc', $type='number') {
 if(is_array($array)) {
  foreach($array as $val) {
   $order_arr[] = $val[$keyid];
  }
  $order = ($order == 'asc') ? SORT_ASC: SORT_DESC;
  $type = ($type == 'number') ? SORT_NUMERIC: SORT_STRING;
  array_multisort($order_arr, $order, $type, $array);
 }
}

Copy after login

I hope this article will be helpful to everyone’s PHP programming design.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/1030141.htmlTechArticleThe method of array_multisort in php to sort multi-dimensional arrays, arraymerge multi-dimensional array. This article describes the example of array_multisort in php to sort multi-dimensional arrays. method. Share it with everyone for your reference...
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template