Advertisement
Guest User

Untitled

a guest
Sep 3rd, 2011
182
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.57 KB | None | 0 0
  1. /*
  2. * sort a multi demensional array on a column
  3. * @author Jeroen Fiege
  4. * @source: http://shiflett.org/blog/2011/jun/sorting-multi-dimensional-arrays-in-php
  5. *
  6. * @param array $array array with hash array
  7. * @param mixed $column key that you want to sort on
  8. * @param enum $order asc or desc
  9.  
  10.  
  11. */
  12.  
  13. function array_qsort2 (&$array, $column=0, $order="ASC") {
  14.  
  15. $oper = ($order == "ASC")?">":"<";
  16.  
  17. if(!is_array($array)) return;
  18.  
  19. usort($array, create_function('$a,$b',"return (\$a['$column'] $oper \$b['$column']);"));
  20.  
  21. reset($array);
  22.  
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement