Assuming I have something coming back from a JSON request that essentially looks like this --
$data = array('0'=> array('name' => 'Dr. Smith',
'address' => '3002 Fake Ave.',
'lat' => '34.711158',
'lng' => '-137.803578',
'phone' => '714.939.1324'),
'1' => array('name' => 'Dr. Paul',
'address' => '801 Fake St.',
'lat' => '31.749917',
'lng' => '-137.834388'));
How do I order it by one of the elements? Say if I wanted to sort the whole array of arrays by the Lat
element? And put it back in the $data
element, so I can keep working with it.
I've read the stuff on PHP about usort
and sorting by a sub-array element, but when I try to work with their code examples they aren't working.