array sort field


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

sort a multidimensional array by field


Copy this code and paste it in your HTML
  1. function array_field_sort(&$array, $field) {
  2. $code = "return strnatcmp(\$a['$field'], \$b['$field']);";
  3. $compare = create_function('$a,$b', $code);
  4. uasort($array,$compare);
  5. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.