I need to sort an array in a particular order, sorting by the keys. I know I need to do something like the below but have tried many different variations of the it and cannot get the result I need.
Can anyone help?
An example of the array is below and th results I am looking for for this would be: Connectivity | Contact Centres | Cloud & Hosting | Business Continuity
$solutions = Array ( [Business Continuity] => business-continuity [Connectivity] => connectivity [Cloud & Hosting] => cloud-hosting [Contact Centres] => contact-centres )
function reorder_solutions($a, $b){
$custom = array('Lines & Calls', 'Mobile', 'Connectivity', 'Wifi', 'LAN', 'UC&C', 'Contact Centres', 'Cloud & Hosting', 'Managed Services', 'Security', 'Business Continuity');
foreach ($custom as $k => $v){
if ($k == $b) {
return 0;
}
return ($k < $b) ? -1 : 1;
}
}
uasort($solutions, "reorder_solutions");