I have two arrays, one is a subset. I need to re-order the larger array so that all the items from array one are at the top of it.
array('c', 'e');
array('a', 'b', 'c', 'd', 'e', 'f', 'g');
I want the 2nd array to look like this:
array('c', 'e', 'a', 'b', 'd', 'f', 'g');
“c” and “e” are at the top of it.
You can use
usortand move the elements up if the other array contains the element:e.g:
This won’t take into consideration the order of
$a, but will allow duplicate elements (if required).