Created
February 10, 2014 15:11
-
-
Save WenLiangTseng/8917588 to your computer and use it in GitHub Desktop.
PHP 使用子陣列中的值,來搜尋陣列中的元素 PHP Sort Array By SubArray Value
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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