您好我想排序数组可以任何人告诉我这里是阵列。 我希望按日期排序,因为你可以看到有数据
2015年5月20日
2015年6月6日
Array ( [1] => Array ( [schedule] => WEEKENDS [title] => 2015-05-20 [track] => 6:00 Pm - 9:20 Pm [days] => May 20, 21, 27, 28 June 3, 4 ) [2] => Array ( [schedule] => WEEKENDS [title] => 2015-05-23 [track] => 9:00 Am - 2:30 Pm [days] => May 23, 24 & May 30, 31 ) [3] => Array ( [schedule] => WEEKENDS [title] => 2015-06-6 [track] => Timing will posted soon... [days] => June 06, 07 & June 13, 14 ) ) Array ( [0] => Array ( [schedule] => EVENINGS [title] => 2015-05-16 [track] => 9:00am
- 2:30pm [days] => May 16, 17, 18 & 19 ) ) Array ( [0] => Array ( [schedule] => EVENINGS [title] => 2015-05-16 [track] => 9:00am - 2:30pm [days] => May 16, 17, 18 & 19 ) [2] => Array ( [schedule] => WEEKENDS [title] => 2015-05-25 [track] => 9:00am - 2:30pm [days] => May 16, 17, 18 & 19 ) ) Array ( [0] => Array ( [schedule] => WEEKENDS [title] => 2015-06-30 [track] => 10:00am - 12:30pm [days] => June 2,4 ) ) Array ( [0] => Array ( [schedule] => EVENINGS [title] => 2015-05-17 [track] => 9:00am - 2:30pm [days] => June 2,4,5,8 ) ) Array ( [0] => Array ( [schedule] => 4DAYS [title] => 2015-05-18 [track] => 9:00am - 2:30pm [days] => May 16, 17, 18 & 19 ) )
答案 0 :(得分:0)
您可以像这样制作自己的排序功能。
它根据“标题”键的值进行排序。
$array = array(
array("title" => "2015-05-20",
"schedule" => "WEEKENDS"
),
array("title" => "2015-05-16",
"schedule" => "WEEKENDS"
)
);
function sortByTitle($a, $b) {
return $a['title'] - $b['title'];
}
usort($array , 'sortByTitle');
print_r($array);
返回:
Array
(
[0] => Array
(
[title] => 2015-05-16
[schedule] => WEEKENDS
)
[1] => Array
(
[title] => 2015-05-20
[schedule] => WEEKENDS
)
)