array_flip multidimensional php code example

Example 1: php sort multidimensional array

function sortByAge($a, $b) {
    return $a['age'] > $b['age'];
}
$people=[
    ["age"=>54,"first_name"=>"Bob","last_name"=>"Dillion"],
    ["age"=>22,"first_name"=>"Sarah","last_name"=>"Harvard"],
    ["age"=>31,"first_name"=>"Chuck","last_name"=>"Bartowski"]
];

usort($people, 'sortByAge'); //$people is now sorted by age (ascending)

Example 2: multidimensional array in php

<?php 
/* 
There are 3 Types of array in php  
1. Indexed arrays - Arrays with a numeric index
2. Associative arrays - Arrays with named keys
3. Multidimensional arrays - Arrays containing one or more arrays

This is the third one - Multidimensional arrays
*/

$carsModel = array
  (
  array("Maruti",21,28),
  array("BMW",05,75),
  array("Tata",25,12),
  array("Land Rover",11,20)
  );
?>