Answers for "sort two diamensional array php"

PHP
0

sort two diamensional array php

<?php

$data=[
  ['name'=>'Tamil',"distance"=>44],
  ['name'=>'Tamil',"distance"=>4],
  ['name'=>'Tamil',"distance"=>14],
  ['name'=>'Tamil',"distance"=>24],  
  ['name'=>'Tamil',"distance"=>10]
];
 
 for($i=0;$i<count($data);$i++)
 {
    for($j=$i;$j<count($data);$j++)
    {
        if($data[$i]['distance']>$data[$j]['distance'])
        {
            $temp=$data[$i];
            $data[$i]=$data[$j];
            $data[$j]=$temp;
        }
    }
 }
 
 print_r($data);

#tamilarasan nallairsun
Posted by: Guest on June-07-2021

Code answers related to "sort two diamensional array php"

Browse Popular Code Answers by Language