林中侠客

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理
<?php

    $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 "<br />";
    echo "<br />";
    echo "<br />";
    uasort( $arr,create_function('$a, $b', 'return $a[\'line_num\'] < $b[\'line_num\'];') );
    print_r($arr);
    echo "<br />";
    echo "<br />";
    echo "<br />";
    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
        )
)
<br /><br /><br />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
        )
)
<br /><br /><br />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
        )
)

 

posted on 2012-12-04 14:40  林中侠客  阅读(239)  评论(0编辑  收藏  举报