Sort array in descending order in PHP

Description

The following code shows how to sort array in descending order.

Example


//from w  w w  .j a v  a 2s.c  o m
<?php
   $a1=array("Dog","Dog","Cat");
   $a2=array("XML","HTML","CSS");
   array_multisort($a1,SORT_ASC,$a2,SORT_DESC);
   print_r($a1);
   print_r($a2);
?>

The code above generates the following result.





















Home »
  PHP Tutorial »
    Data Types »




Array
Array Associative
Array Util
ArrayObject
Data Types
Date
Date Format
DateTime
Number
String
String Escape
String Filter
String HTML
String Type
Timezone