给定存储在$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