我有这个数组;
Array
(
[2017-04-01] => 0
[2017-04-02] => 0
[2017-04-03] => 0
[2017-04-04] => 0
[2017-04-05] => 0
)
如何格式化日期以获得类似的内容?
Array
(
[01-04-2017] => 0
[02-04-2017] => 0
[03-04-2017] => 0
[04-04-2017] => 0
[05-04-2017] => 0
)
感谢。
答案 0 :(得分:1)
一个简单的foreach
循环然后转换为d-m-Y
格式可以执行此操作
$result = [];
foreach ($datas as $key => $value) {
$date = date('d-m-Y', strtotime($key));
$result[$date] = $value;
}
print_r($result);