R4R Team working to provide free of cost for experienced and freshers

Tutorials | Examples|Interview Questions and Answers|Java Tutorials| C Tutorials | C++ Tutorials | Spring Tutorials| Hibernate Tutorials | JSP Tutorials | Servelets Tutorials| C# Tutorials | PHP Tutorials etc , Basics | Download Software | Data Types | Variables | Constant | Storage & Classes | Operators | Decisions Making | Loops | Functions| Numbers | Arrays | Pointers | String | Datastructure | Expressions | Preprocessor Statement | I/O | Exception Handling | OOPs Tutorial | Classes and object |C++ Inheritance Overloading | Polymorphism | Abstraction | Encapsulation | Interfaces | Multithreading etc

PHP Programing language

array_multisort() Function in PHP
Previous Home Next


The array_multisort() function returns a sorted array. You can assign one or more arrays. The function sorts the first array, and the another arrays follow, then, if two or more values are the same, it sorts the next array, and so on.

array_multisort(array1,sorting order,sorting type,array2,array3...)

In above syntax, "array1" specifies an array, "sorting order" specifies the sorting order and values are as follows:

  • SORT_ASC: Sort in ascending order and is default order (A-Z)
  • SORT_DESC: Sort in descending order (Z-A)
"sorting type" specifies the type to use, when comparing elements and values are as follows:
  • SORT_REGULAR: Compare elements normally (Standard ASCII) and is default type
  • SORT_NUMERIC: Compare elements as numeric values
  • SORT_STRING: Compare elements as string values
  • SORT_LOCALE_STRING: Compare elements as string, based on the current locale (can be changed using setlocale())
  • SORT_NATURAL: Compare elements as strings using "natural ordering" like natsort()
  • SORT_FLAG_CASE: Can be combined (bitwise OR) with SORT_STRING or SORT_NATURAL to sort strings case-insensitively
"array2" specifies an array and "array3" specifies an array




Array ( [0] => Apple [1] => Banana [2] => Orange ) Array ( [0] => Onion [1] => Tomato [2] => Potato )

Previous Home Next