fork download
  1. <?php
  2.  
  3. $arr = array('willion','kevien','john','smith');
  4.  
  5. $orderedArr = array('anne','bold','hellen','john','kevien','polm','smith','willion');
  6.  
  7. $orderedUsers = array();
  8. foreach ($orderedArr as $data) {
  9. if(in_array($data,$arr))
  10. {
  11. $orderedUsers[] = $data;
  12. }
  13. }
  14.  
  15. var_dump($orderedUsers);
Success #stdin #stdout 0.01s 20520KB
stdin
Standard input is empty
stdout
array(4) {
  [0]=>
  string(4) "john"
  [1]=>
  string(6) "kevien"
  [2]=>
  string(5) "smith"
  [3]=>
  string(7) "willion"
}