How to bring a chosen array key to the top of the array?

Silentone

New Member
Let's say I have an array as follows:\[code\]$food['fruit'] = array('apples','oranges','bananas');$food['veg'] = array('potatoes','onions','peppers');$food['meat'] = array('bacon','beef','chicken');\[/code\]How would I go about ordering it such that any given type of food would be brought to the top of the array and the rest of the order remains intact?So if the user selected 'veg' it'd change the order to:\[code\]$food = array('veg' => ..., 'fruit' => ..., 'meat' => ...);\[/code\]
 
Back
Top