- $arr = array(
- "0" => array(line_num => "10", occur_time => "2007-11-19 10:25:04+08"),
- "1" => array(line_num => "9", occur_time => "2007-11-19 10:25:04+08"),
- "2" => array(line_num => "25", occur_time => "2007-11-19 10:25:04+08")
- );
- print_r($arr);
- echo "
"; - echo "
"; - echo "
"; - uasort( $arr,create_function('$a, $b', 'return $a[\'line_num\'] < $b[\'line_num\'];') );
- print_r($arr);
- echo "
"; - echo "
"; - echo "
"; - foreach($arr as $key => $value) {
- $ar[] = $value;
- }
- print_r($ar);
- ?>
输出结果:
Array
(
[0] => Array
(
[line_num] => 10
[occur_time] => 2007-11-19 10:25:04+08
)
[1] => Array
(
[line_num] => 9
[occur_time] => 2007-11-19 10:25:04+08
)
[2] => Array
(
[line_num] => 25
[occur_time] => 2007-11-19 10:25:04+08
)
)
Array
(
[2] => Array
(
[line_num] => 25
[occur_time] => 2007-11-19 10:25:04+08
)
[0] => Array
(
[line_num] => 10
[occur_time] => 2007-11-19 10:25:04+08
)
[1] => Array
(
[line_num] => 9
[occur_time] => 2007-11-19 10:25:04+08
)
)
Array
(
[0] => Array
(
[line_num] => 25
[occur_time] => 2007-11-19 10:25:04+08
)
[1] => Array
(
[line_num] => 10
[occur_time] => 2007-11-19 10:25:04+08
)
[2] => Array
(
[line_num] => 9
[occur_time] => 2007-11-19 10:25:04+08
)
)
>>> 更多内容,请查看 php数组排序方法大全 <<< |