O'Reilly logo

Programming PHP, 3rd Edition by Peter MacIntyre, Kevin Tatroe, Rasmus Lerdorf

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Name

array_multisort

Synopsis

bool array_multisort(array array1[, SORT_ASC|SORT_DESC
    [, SORT_REGULAR|SORT_NUMERIC|SORT_STRING]] [, array array2[, SORT_ASC|SORT_DESC
    [, SORT_REGULAR|SORT_NUMERIC|SORT_STRING]], ...])

Used to sort several arrays simultaneously, or to sort a multidimensional array in one or more dimensions. The input arrays are treated as columns in a table to be sorted by rows—the first array is the primary sort. Any values that compare the same according to that sort are sorted by the next input array, and so on.

The first argument is an array; following that, each argument may be an array or one of the following order flags (the order flags are used to change the default order of the sort):

SORT_ASC (default)

Sort in ascending order

SORT_DESC

Sort in descending order

After that, a sorting type from the following list can be specified:

SORT_REGULAR (default)

Compare items normally

SORT_NUMERIC

Compare items numerically

SORT_STRING

Compare items as strings

The sorting flags apply only to the immediately preceding array, and they revert to SORT_ASC and SORT_REGULAR before each new array argument.

This function returns true if the operation was successful and false otherwise.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required