Posted By

jmiller on 08/19/10


Tagged

sort array field order


Versions (?)

Sort a multi-dimensional field


 / Published in: PHP
 

Orders a multi-dimensional field (such as sorting multiple $orders by field 'id')

  1. function orderBy($data, $field) {
  2. $code = "return strnatcmp(\$a['$field'], \$b['$field']);";
  3. usort($data, create_function('$a,$b', $code));
  4. return $data;
  5. }

Report this snippet  

You need to login to post a comment.