<?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
)
)