336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.

$test = array(

array("name" => "someone1", "reg_date" => "2013-04-01 13:00:00"),

array("name" => "someone2", "reg_date" => "2013-04-01 13:01:00"),

array("name" => "someone3", "reg_date" => "2013-04-01 12:00:00")

);

이와 같은 배열이 있다고 할 때, reg_date별로 정렬하고 싶다면 아래와 같이 한다.


 

usort($test, function($a1, $a2) {

$v1 = strtotime($a1->reg_date);

$v2 = strtotime($a2->reg_date);

return $v2 - $v1; // $v2 - $v1 : 내림차순, $v1 - $v2 : 오름차순

});


foreach($test as $a) {
    echo $a->name . ' ' . $a->reg_date . "<br>";
}

결과)
someone2 2013-04-01 13:01:00
someone1 2013-04-01 13:00:00
someone3 2013-04-01 12:00:00

posted by 어린왕자악꿍