Array Push with associative to array?
$row_properties = array(
"Header 11"=>array("width"=>20,"align"=>'C',"color"=>array(100,220,255),"text_color"=>array(220,50,50)),
"Header 12"=>array("width"=>20,"align"=>'C',"color"=>array(100,220,255),"text_color"=>array(220,50,50) )
);
How I can Push the values
"Header 13"=>array("width"=>20,"align"=>'C',"color"=>array(100,220,255) ,"text_color"=>array(220,50,50)),
"Header 14"=>array("width"=>20,"align"=>'C',"color"=>array(100,220,255) ,"text_color"=>array(220,50,50)),
SO it will got the result
$row_properties = array(
"Header 11"=>array("width"=>20,"align"=>'C',"color"=>array(100,220,255),"text_color"开发者_如何学C=>array(220,50,50)),
"Header12"=>array("width"=>20,"align"=>'C',"color"=>array(100,220,255),"text_color"=>array(220,50,50),
"Header 13"=>array("width"=>20,"align"=>'C',"color"=>array(100,220,255) ,"text_color"=>array(220,50,50)),
"Header 14"=>array("width"=>20,"align"=>'C',"color"=>array(100,220,255) ,"text_color"=>array(220,50,50))
)
);
Simple
$row_properties["Header 13"] = array("width"=>20,"align"=>'C',"color"=>array(100,220,255) ,"text_color"=>array(220,50,50));
Tried the array_merge()
function?
Maybe something like this:
$push_vals = array(
"Header 13"=>array("width"=>20,"align"=>'C',"color"=>array(100,220,255) ,"text_color"=>array(220,50,50)),
"Header 14"=>array("width"=>20,"align"=>'C',"color"=>array(100,220,255) ,"text_color"=>array(220,50,50)),
);
$arr = array(
"Header 11"=>array("width"=>20,"align"=>'C',"color"=>array(100,220,255),"text_color"=>array(220,50,50)),
"Header 12"=>array("width"=>20,"align"=>'C',"color"=>array(100,220,255),"text_color"=>array(220,50,50)
);
foreach ($push_vals as $key=>$value){
if ( isset($arr[$key]) )
$arr = array_merge($arr[$key], $push_vals[$key]);
else
$arr[$key] = $push_vals[$key];
}
Update
durrr array_merge_recursive
精彩评论