I have this array:

$arr['success'][] = array( "id" => $out[$c_id], "nick" => $out[$c_nick], "inv" => $out[$c_inv] ); 

I need to sort the output from "inv" in ascending order, how can this be implemented?

  • Do you want $arr['success'] sort ascending the key value of inv ? - Alex
  • Alex, this is exactly what I want to do. - Febest
  • Show an example of an array before and after. And the code that you tried to write. - E_p

1 answer 1

 function cmp ($ALeft, $Aright) { if ($ALeft['inv'] < $Aright['inv']) return -1; if ($ALeft['inv'] == $Aright['inv']) return 0; return 1; } usort($arr['success'], 'cmp');