Sort a multi-dimensional field

/ Published in: PHP
Save to your folder(s)

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

Copy this code and paste it in your HTML
  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


RSS Icon Subscribe to comments

You need to login to post a comment.