年/月的数组 [英] array of year/months
问题描述
大家好,
它有任何简单的方法可以动态创建数年和数月的数组
(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屋!