Suggest a feature
×

Welcome to TagMyCode

Please login or create account to add a snippet.
0
0
 
0
Language: PHP
Posted by: M. Chris
Added: Feb 19, 2018 9:48 AM
Views: 17
Tags: no tags
  1.  
  2.     private function sortArrayByUserDefinedList(array $array,array $list, $field)
  3.     {
  4.         $sortedArray = $list;
  5.         foreach ($array as $key => $value) {
  6.             if (false !== $indice = array_search($array[$key][$field], $list)) {
  7.                 $sortedArray[$indice] = $value;
  8.             }
  9.         }
  10.         return $sortedArray;
  11.     }