I have an array like below
Array
(
[0] => Array
(
[text] => one
[mp3] => 1.mp3
)
[1] => Array
(
[text] => two
[mp3] => 2.mp3
)
[2] => Array
(
[text] => three
[mp3] => 3.mp3
)
)
And I have another array with index to sort array(1,0,2) ,So With these I want following
Array
(
[0] => Array(
[text] => two[mp3] => 2. mp3
)
[1] => Array(
[text] => one[mp3] => 1. mp3
)
[2] => Array(
[text] => three[mp3] => 3. mp3
)
)
I googled and Found Few solutions on stackoverflow , But None seems to be successful for me
$order=array(1,0,2);
$orderedarray = array_merge(array_flip($order),$myarr);
$myarr = $orderedarray;
print_r($myarr);
Which outputs following
(
[0] => 0
[1] => 1
[2] => 2
[3] => Array
(
[text] => one
[mp3] => 1.mp3
)
[4] => Array
(
[text] => two
[mp3] => 2.mp3
)
[5] => Array
(
[text] => three
[mp3] => 3.mp3
)
)