年/月的数组 [英] array of year/months

查看:89
本文介绍了年/月的数组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,


它有任何简单的方法可以动态创建数年和数月的数组

(2个循环)用于关联数组?

到目前为止我已经尝试过了:(最后一行有一个错误,带有=>符号。


$ table = array();

for($ i = 2005; $ i< = date(''y''); $ i ++){

$ table = array_push ($ i => array());

for($ d = 1; $ d< = 12; $ d ++)

$ table [$ i] = array_push($ table,$ i => 0);

}


我需要的是创建一个表,然后使用它编写和重写

$ table [$ year] [$ month] = $ somevalue;


感谢您的帮助。

解决方案

table = array();

for(


i = 2005;


I< =日期( '' Y '');

Hi all,

it''s there any simple way to create an array of years and months dynamically
(2 loops) for an associative array ?
I''ve tried this so far: (having an error on last line with the "=>" sign.

$table = array();
for($i=2005;$i<=date(''y'');$i++){
$table = array_push($i=>array());
for($d=1;$d<=12;$d++)
$table[$i] = array_push($table,$i=>0);
}

What I need is to create a table wich will then be written and readed using
$table[$year][$month] = $somevalue;

Thanks for helping.

解决方案

table = array();
for(


i=2005;


i<=date(''y'');


这篇关于年/月的数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆