我有以下数组:
( [0] => Array ( [schedules] => Array ( [monday] => 1 [tuesday] => 1 [wednesday] => 1 [thursday] => 1 [friday] => 1 [saturday] => 0 [sunday] => 1 ) ) )
我想用第一个键是明天那天对这个数组的元素进行排序.让我们说今天是星期三.我希望我的数组看起来像这样:
( [0] => Array ( [schedules] => Array ( [thursday] => 1 [friday] => 1 [saturday] => 0 [sunday] => 1 [monday] => 1 [tuesday] => 1 [wednesday] => 1 ) ) )
我已经有了工作日可用(例如字符串’星期四’).它被传递到我正在使用的函数中.
有关实现此类排序的任何建议吗?谢谢!
如果将日期转换为数字0-6,则可以多次使用array_shift和array_push将前几天移动到数组的末尾.