top button
Flag Notify
    Connect to us
      Facebook Login
      Site Registration Why to Join

Facebook Login
Site Registration

How can I sort a multi-dimensional array?

0 votes
How can I sort a multi-dimensional array?
posted Jun 26, 2014 by Karamjeet Singh

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

2 Answers

+1 vote

By using an inbuilt function array_multisort() we can achieve

$ar = array(
       array("10", 11, 100, 100, "a"),
       array(   1,  2, "2",   3,   1)
array_multisort($ar[0], SORT_ASC, SORT_STRING,
                $ar[1], SORT_NUMERIC, SORT_DESC);
answer Jun 27, 2014 by Shiva Chawala
0 votes

This can be done using the function in PHP that is called array_multisort.

For Example:

<?php $multiarray = array(array(5,4,3,2,1),array(7,8,2,9,10)); array_multisort($multiarray[0],SORT_ASC); print_r($multiarray); ?>

answer Jun 27, 2014 by Mohit Sharma
Similar Questions
0 votes
if (filter_var($data[$i][1], FILTER_VALIDATE_EMAIL)){
echo $data[$i][1];
$conn = mysqli_connect($dbhost,$dbuser,$dbpass, $dbname);
if ($conn->connect_error) {
  die("Connection failed: " . $conn->connect_error);
$sql ="INSERT INTO promo_user (uid,name,email) VALUES (,'', '$email')";

I am using the above code but there is something wrong with it,whenever i run the code the echo is working fine but the content does go into sql table

Please help

Contact Us
+91 9880187415
#280, 3rd floor, 5th Main
6th Sector, HSR Layout
Karnataka INDIA.