我确实看过了,但我仍然有点困惑……
这是$myobject对象的样子:
Array ( [0] => stdClass Object ( [tid] => 13 [vid] => 4 ) [1] => stdClass Object ( [tid] => 10 [vid] => 4 ) [2] => stdClass Object ( [tid] => 34 [vid] => 4 ) [3] => stdClass Object ( [tid] => 9 [vid] => 4 )
我看到了这个:
function cmp( $a,$b ) { if( $a->weight == $b->weight ){ return 0 ; } return ($a->weight < $b->weight) ? -1 : 1; } usort($myobject,'cmp');
我试图按照tid排序,但是,我想我真的不确定我是否必须改变体重?或者它会按原样工作吗?我试过了,但没有输出……