PHP - Function array_multisort()
Syntax
array_multisort(array1,sorting order,sorting type,array2...);
Definition and Usage
This can be used to sort several arrays at once, or a multi-dimensional array by one or more dimensions.
Parameters
| Sr.No | Parameter & Description |
|---|---|
| 1 |
array1(Required) It specifies an array |
| 2 | Sort order(Optional) It specifies the sorting order. Possible values −
|
| 3 |
Sorting type(Optional) It specifies the type to use, when comparing elements. Possible values −
|
| 4 |
array2(Optional) It specifies an array |
Return Values
It returns TRUE on success or FALSE on failure.
Example
Try out following example −
<?php
$input1 = array("10", 100, 100, "a");
$input2 = array(1, 3, "2", 1);
array_multisort($input1, $input2);
print_r($input1);
print_r($input2);
?>
This will produce the following result −
Array ( [0] => 10 [1] => a [2] => 100 [3] => 100 ) Array ( [0] => 1 [1] => 1 [2] => 2 [3] => 3 )
php_function_reference.htm
Advertisements