Share on Google+Share on Google+

PHP MultiArray Sorting

Advertisement
PHP MultiArray Sorting: This tutorial has covered the sorting process of multi-dimensional array, have a look on the examples of multi array sorting

PHP Array Sort Multidimensional

PHP provides array_multisort() function to sort more than one array at a time or multi-dimensional array. String keys will be maintained but the numeric keys will be re-indexed. A little description of array_multisort() is as follows:

General Format bool array_multisort ( array $arr [, mixed $arg[,...]] )
Parameters arr: an array, arg: optionally another array
Return Value True/False

Example 1:

<?php

$array1=array(10,15,2,33,69);

$array2=array(2,33,55,856,1456);

array_multisort($array1,$array2);

print_r($array1);

echo"<br/>";

print_r($array2);

?>

Output:

Array ( [0] => 2 [1] => 10 [2] => 15 [3] => 33 [4] => 69 ) Array ( [0] => 55 [1] => 2 [2] => 33 [3] => 856 [4] => 1456 )

 

Advertisements

Posted on: October 22, 2009 If you enjoyed this post then why not add us on Google+? Add us to your Circles

Share this Tutorial Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.