給定存儲在$my_array
中的對象數組,我想提取最高值爲count
的2個對象,並將它們放置在單獨的對象數組中。該陣列結構如下。對象數組,提取最高值
我該怎麼做呢?
array(1) {
[0]=> object(stdClass)#268 (3) {
["term_id"]=> string(3) "486"
["name"]=> string(4) "2012"
["count"]=> string(2) "40"
}
[1]=> object(stdClass)#271 (3) {
["term_id"]=> string(3) "488"
["name"]=> string(8) "One more"
["count"]=> string(2) "20"
}
[2]=> object(stdClass)#275 (3) {
["term_id"]=> string(3) "512"
["name"]=> string(8) "Two more"
["count"]=> string(2) "50"
}
值得評論匿名函數將只在PHP工作5.3+ – sberry 2012-04-27 16:07:48
@sberry:謝謝,我會予以注意。 – FtDRbwLXw6 2012-04-27 16:09:21
+1 - 對我來說很不錯。 – sberry 2012-04-28 01:16:40