I have two arrays and I want to sort first array in ascending order where as I want second array sorted in descending order in PHP.
So I used array_multisort() function. The first array is sorted as expected but the second array is not sorted as I wish.
Below is the code.
<?php
$array1 = array("ninja","pirate","assasin","superhero");
$array2 = array("elephant","panda","eagle","snake");
echo "<pre>";
echo "Array 1.) <br />";
print_r($array1);
echo "<hr />Array 2.) <br />";
print_r($array2);
array_multisort($array1,SORT_ASC,$array2,SORT_DESC);
echo "<hr/>New Sorted Array 1.) <br />";
print_r($array1);
echo "<hr />";
echo "New Sorted Array 2.) <br />";
print_r($array2);
echo "</pre>";
?>
I am a beginner in PHP. Please comment below for any query.