<code>$test=array(60) { [0]=> object(stdClass)#14 (3) { ["id"]=> string(3) "609" ["title"]=> string(19) "Physical Mechanisms" ["publish_time"]=> string(10) "6 MAY 2016" } [1]=> object(stdClass)#14 (3) { ["id"]=> string(3) "610" ["title"]=> string(20) "Engineering Substrate" ["publish_time"]=> string(10) "2 MAY 2016" } ...} </code>
publish_time에 따라 $test를 정렬하는 방법은 무엇입니까? 찾다!
<code>$test=array(60) { [0]=> object(stdClass)#14 (3) { ["id"]=> string(3) "609" ["title"]=> string(19) "Physical Mechanisms" ["publish_time"]=> string(10) "6 MAY 2016" } [1]=> object(stdClass)#14 (3) { ["id"]=> string(3) "610" ["title"]=> string(20) "Engineering Substrate" ["publish_time"]=> string(10) "2 MAY 2016" } ...} </code>
publish_time에 따라 $test를 정렬하는 방법은 무엇입니까? 찾다!
php 함수 usort를 사용하여 정렬을 사용자 정의할 수 있습니다
<code><?php function _usort($a, $b) { if ( strtotime($a->publish_time) < strtotime($a->publish_time) ) { return -1; } else if( strtotime($a->publish_time) > strtotime($a->publish_time) ){ return 1; } else { return 0; } } usort($arr, '_usort');</code>