开发者

Turning this array

I have a graph, which shows stats for the latest 7 days. They are shown like this:

Today - 17-09 - 16-09 - 15-09 开发者_JAVA技巧- 14-09 - 13-09 - 12-09

The PHP looks like this:

$days = array('Today');
for ($i = 1; $i < 7; $i++) {
    $days[$i] = date('d-m', strtotime('-' . ($i + 0) . ' day'));
}

My question is, how can I do so it will look like this:

12-09 - 13-09 - 14-09 - 15-09 - 16-09 - 17-09 - Today

Thanks in advance.


Try this:

$days = array_reverse($days);

Otherwise you can generate it in reverse order:

 $days = array();
    for ($i=6; $i>=1;$i--)
    {
      $days[] = date('d-m', strtotime('-'.($i+0).' day'));
    }
 $days[] = 'Today';


You might also try:

    for ($i=0; $i<6;$i++)
    {
      $days[6-$i] = date('d-m', strtotime('-'.(6-$i+0).' day'));
    }
 $days[6] = array('Today');
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜