fork download
  1. <?php
  2.  
  3. // your code goes here
  4.  
  5. $array = [3=>'Mothers Day',1=>'Birthday'];
  6.  
  7. $order = [
  8. 'Birthday' => 1,
  9. 'Congratulations' => 2,
  10. 'Halloween' => 3,
  11. 'Christmas' => 4,
  12. 'Mothers Day' => 5
  13. ];
  14.  
  15. uasort($array, function($a,$b) use ($order){
  16. return $order[$a] > $order[$b];
  17. });
  18.  
  19. print_r($array);
Success #stdin #stdout 0.02s 24448KB
stdin
Standard input is empty
stdout
Array
(
    [1] => Birthday
    [3] => Mothers Day
)