I have an array:
$example = array();
$example ['one'] = array('first' => 'blue',
'second' => 'red');
$example ['two'] = array('third' => 'purple',
'fourth' => 'green');
$example ['three'] = array('fifth' => 'orange',
'sixth' => 'white');
Based on some function input, I need to reorder the array example before the foreach loop processes my output:
switch($type)
case 'a':
break;
case 'b':
break;
case 'c':
break;
foreach($example as $value){
echo $value;
}
Is there an easy way to do this without reorganizing all my code? I have a pretty simple foreach loop that does the processing, and if there was an easy way to simply reorder the array every time, that would be really useful.
source
share