Consider the following array:
$main_array = array();
$main_array[0] = array('location'=> array('France', 'Germany'), 'random_number'=> array('6520'));
$main_array[1] = array('location'=> array('Italy', 'Switzerland'), 'random_number'=> array('3245'));
$main_array[2] = array('location'=> array('Portugal', 'Spain'), 'random_number'=> array('9981'));
$main_array[3] = array('location'=> array('Turkey', 'Greece'), 'random_number'=> array('1098'));
I want to sort this array by the value of random_number[0]
key and based on the sequence of the following array:
$sequenced = array('3245','1098','6520','9981');
So the final sorted array would look like:
$final_array = array();
$final_array[0] = array('location'=> array('Italy', 'Switzerland'), 'random_number'=> array('3245'));
$final_array[1] = array('location'=> array('Turkey', 'Greece'), 'random_number'=> array('1098'));
$final_array[2] = array('location'=> array('France', 'Germany'), 'random_number'=> array('6520'));
$final_array[3] = array('location'=> array('Portugal', 'Spain'), 'random_number'=> array('9981'));
Any idea how that would be achieved?