If you want to change the order programmatically, look at the various array sorting functions in PHP , especially
uasort() - sort an array with a custom comparison function and maintain index associationuksort() - sorting an array using a custom comparison functionusort() - Sorting an array by values using a custom comparison function
Based on the Yannicks example below, you can do it like this:
$a = array(0 => 'a', 1 => 'b', 2 => 'c', 3 => 'd');
$b = array(3, 2, 0, 1);
$c = array();
foreach($b as $index) {
$c[$index] = $a[$index];
}
print_r($c);
will give
Array([3] => d [2] => c [0] => a [1] => b)
, , , , .