Skip to content

Instantly share code, notes, and snippets.

@WenLiangTseng
Created February 10, 2014 15:11
Show Gist options
  • Save WenLiangTseng/8917588 to your computer and use it in GitHub Desktop.
Save WenLiangTseng/8917588 to your computer and use it in GitHub Desktop.
PHP 使用子陣列中的值,來搜尋陣列中的元素 PHP Sort Array By SubArray Value
<?php
//Source http://stackoverflow.com/questions/2477496/php-sort-array-by-subarray-value
//Use usort function and custom criteria.
function cmp_by_optionNumber($a, $b) {
return $a["optionNumber"] - $b["optionNumber"];
}
//and
usort($array, "cmp_by_optionNumber");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment