Array function library: Array_multisort

Source: Internet
Author: User
Keywords array_multisort php Chinese function manual array function library
Tags aliyun array array function library array_multisort example function function library html

Array_multisort

(PHP4 >= 4.0b4)

Array_multisort---&http://www.aliyun.com/zixun/aggregation/37954.html ">nbsp; Array of sorted composite or multiple dimensions

Syntax: bool Array_multisort (Array ar1 [, mixed arg [, mixed ... [, array ...]]

Description:

Array_multisort () can be used to sort a number of arrays or multiple dimensions (multi-dimensional) arrays immediately.

The input array is considered to be the field of the table. Sort it by column (rows), which is similar to the SQL ORDER BY clause function, the first array is the first (primary) sorted array, and the column (value) in this array is the same sort of array as the one entered.

The argument structure of this function is a unique (unusual) bit, but is flexible. The first argument must be an array, and then the argument can be one of the array or the sort flag (flag) of the next list.

Sort order Flag:

SORT_ASC-Sort into ascending order
Sort_desc-Sort into descending order

Sort Type flag:

Sort_regular-Normal comparison project
Sort_numeric-With a digital comparison project

Sort_string-as a string to compare items

You cannot use two identical flags to specify that after each array, the sorted flag is specified after the array argument, only for this array, and the others are reset to the preset sort_asc and sort_regular after the array argument.

Success returns TRUE, and failure returns false.

Example:

<?php

$ar 1 = Array ("a");

$ar 2 = Array (1, 3, "2", 1);

Array_multisort ($ar 1, $ar 2);

?>

After this example is sorted, the first array will be ten, "a", 100, 100, and the second array will be 1, 1, 2, "3".

Example:

<?php

$ar = Array ("Ten", "N", "a"), Array (1, 3, "2", 1));

Array_multisort ($ar [0], SORT_ASC, sort_string,

$ar [1], sort_numeric, SORT_DESC);

?>

After this example is sorted, the first array will be ten, "a" (It is considered a string and ascending sort), and the second array will be 1, 3, "2", 1 (it is considered numeric and descending sort).

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.