I have this static array:
$elems = array(
date($format, strtotime("12-12-12"))
=> array(
"Title" => "title1",
"Color" => "color1"),
date($format, strtotime("12-12-11"))
=> array(
"Title" => "title2",
"Color" => "color2"),
);
which I want to turn into a dynamic array (with the same elements) .
for some reason the following code isn’t good:
$elems = array();
$elems[] = date($format, strtotime("12-12-12"))
=> array(
"Title" => "title1",
"Color" => "color1");
$elems[] = date($format, strtotime("12-12-11"))
=> array(
"Title" => "title2",
"Color" => "color2");
why isn’t it good?
and how should I fix it?
You can do:
And in general
$array = array('key' => 'value');is the same as$array['key'] = 'value';.Also take a look at documentation.