fork download
  1. <?php
  2.  
  3. $a = array(
  4. 1 => 2,
  5. 2 => 1,
  6. 3 => 7,
  7. 4 => 3,
  8. 5 => 4,
  9. 6 => 5,
  10. 7 => 6
  11. );
  12.  
  13. $b = array(
  14. 1 => "Ask the Exec",
  15. 2 => "Acquisition newsletters",
  16. 3 => "Business plan strategic themes guide",
  17. 4 => "Byte Size News",
  18. 5 => "Corporate videos - e.g. acquisitions, financial results etc.",
  19. 6 => "Portal",
  20. 7 => "Team Briefs/Team Meetings"
  21. );
  22.  
  23.  
  24. asort($a);
  25. $keys = array_keys($a);
  26. array_multisort($keys, $a, $b);
  27. $b = array_combine($a, $b);
  28.  
  29. print_r($b);
Success #stdin #stdout 0.02s 13112KB
stdin
Standard input is empty
stdout
Array
(
    [2] => Acquisition newsletters
    [1] => Ask the Exec
    [7] => Team Briefs/Team Meetings
    [3] => Business plan strategic themes guide
    [4] => Byte Size News
    [5] => Corporate videos - e.g. acquisitions, financial results etc.
    [6] => Portal
)