fork(2) download
  1. <?
  2. $selectedlist=array(3,5);
  3. $alllist=array(1=>'one',2=>'two',3=>'three',4=>'four',5=>'five');
  4.  
  5. $a=array_intersect_key($alllist,array_flip($selectedlist))+$alllist;
  6. print_r($a);
  7. ?>
Success #stdin #stdout 0.02s 13064KB
stdin
Standard input is empty
stdout
Array
(
    [3] => three
    [5] => five
    [1] => one
    [2] => two
    [4] => four
)