I have a multi-dimensional array and have tried every example code I can find from this website to sort it by a column. Not a single snippet I have tried has worked and for some reason all of them result in some strange mess of ordering. I cannot for the life of me figure out what is causing this and hope someone can point it out...
if ($devices_xml = curl_get_file_contents($devices_url))
{
$devices = simplexml_load_string($devices_xml);
$data = array(array());
$counter = 0;
foreach ($devices->item as $device)
{
$data[$counter]["id"] = $device->objid;
$data[$counter]["probe"] = $device->probe;
$data[$counter]["name"] = $device->device;
$counter++;
}
array_sort_by_column($data, "probe");
return $data;
}
return false;
}
My Multi-dimensional sorting function that works for everything else but not this is as follows...
function array_sort_by_column(&$arr, $col, $dir = SORT_ASC)
{
$sort_col = array();
foreach ($arr as $key=> $row)
{
$sort_col[$key] = $row[$col];
}
array_multisort($sort_col, $dir, $arr);
}
The result comes out looking like this. Probe is the test such as "DE-FRANKFURT" at the beginning and name is the second part such as "EU-DE-010"
