Season2 // Array sort by
[code]
function array_sort($array, $on, $order=SORT_ASC){
$new_array = array();
$sortable_array = array();
if (count($array) > 0) {
foreach ($array as $k => $v) {
if (is_array($v)) {
foreach ($v as $k2 => $v2) {
if ($k2 == $on) {
$sortable_array[$k] = $v2;
}
}
} else {
$sortable_array[$k] = $v;
}
}
switch ($order) {
case SORT_ASC:
asort($sortable_array);
break;
case SORT_DESC:
arsort($sortable_array);
break;
}
foreach ($sortable_array as $k => $v) {
$new_array[$k] = $array[$k];
}
}
return $new_array;
}
// 예시
$list = array_sort($list, 'last', SORT_DESC); // Sort by oldest first
[/code]
댓글 3개
감사합니다. ^^
@민트다이어리
이걸 어디다 저장했는지 자꾸 까먹어서 다시 sir에 들어와서 복사해 가네요. 이런거 잘 기억하거나 정리하는 방법이 있을까요?
@울라프 저는 그누 스크랩에 스크랩합니다. ^^
게시판 목록
그누보드5 팁자료실
| 번호 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|
| 공지 | 3년 전 | 4407 | ||
| 2274 | 2년 전 | 2066 | ||
| 2273 |
|
2년 전 | 1487 | |
| 2272 | 2년 전 | 2468 | ||
| 2271 | 2년 전 | 2069 | ||
| 2270 |
|
2년 전 | 2090 | |
| 2269 |
|
2년 전 | 1891 | |
| 2268 | 2년 전 | 3850 | ||
| 2267 | 2년 전 | 2899 | ||
| 2266 |
|
2년 전 | 2123 | |
| 2265 | 2년 전 | 1642 | ||
| 2264 | 2년 전 | 2123 | ||
| 2263 | 2년 전 | 1992 | ||
| 2262 | 2년 전 | 1540 | ||
| 2261 |
|
2년 전 | 1452 | |
| 2260 | 2년 전 | 2441 | ||
| 2259 |
welcome
|
2년 전 | 1778 | |
| 2258 |
welcome
|
2년 전 | 1307 | |
| 2257 | 2년 전 | 3054 | ||
| 2256 | 2년 전 | 1316 | ||
| 2255 |
|
2년 전 | 1824 | |
| 2254 | 2년 전 | 1797 | ||
| 2253 |
welcome
|
2년 전 | 1571 | |
| 2252 |
welcome
|
2년 전 | 1341 | |
| 2251 | 2년 전 | 2396 | ||
| 2250 | 2년 전 | 2032 | ||
| 2249 | 2년 전 | 1818 | ||
| 2248 | 2년 전 | 1630 | ||
| 2247 | 2년 전 | 2055 | ||
| 2246 | 2년 전 | 2466 | ||
| 2245 | 2년 전 | 1918 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기