I have a problem in php, i tried searching but i only got more confused. I need to sort an array according to another array using the "priority" key value.
This is the order i need it filtered with.
$custom_order = array(
array('priority' => 0, 'field_id' => 'password'),
array('priority' => 1, 'field_id' => 'username')
);
And this is the array that needs to be filtered
$default_order = array(
'name' => array(
'username' => array(
'type' => 'text',
'priority' => 0
),
'password' => array(
'type' => 'password',
'priority' => 1
),
),
);
And this is the order that i would like to get
$final_order = array(
'name' => array(
'password' => array(
'type' => 'password',
'priority' => 0
),
'username' => array(
'type' => 'text',
'priority' => 1
),
),
);
I'm confused, i'm not sure whether i should use uasort, or array_intersect, by reading other articles about it i got more confused. Can anybody please explain how would i go to sort the array in this way?
Thank you so much.