array("msg1"=>"asdasd","msg2"=>"dasdsa"));/*----------如何将一个数据添加到数">
时间:2021-07-01 10:21:17 帮助过:21人阅读
输出如下---------------------*/
$a=array("date"=>array
(
"msg1"=>"asdasd",
"msg2"=>"dasdsa")
);
/*----------如何将一个数据添加到数组中,使数组
$a=array("date"=>array("msg1"=>"asdasd","msg2"=>"dasdsa"));
array_push($a['date'],array('msg3'=>'tel'));
print_r($a);
$a=array();
foreach($data as $k=>$v){
$a['date']['msg'.$k]=$v;
}
print_r($a);
$a=array("date"=>array("msg1"=>"asdasd","msg2"=>"dasdsa"));
$a['date']['msg3'] = 'tel';
print_r($a);
Array
(
[date] => Array
(
[msg1] => asdasd
[msg2] => dasdsa
[msg3] => tel
)
)
$a=array("date"=>array("msg1"=>"asdasd","msg2"=>"dasdsa"));
$a['date']['msg3'] = 'tel';
print_r($a);
Array
(
[date] => Array
(
[msg1] => asdasd
[msg2] => dasdsa
[msg3] => tel
)
)
$a=array("date"=>array("msg1"=>"asdasd","msg2"=>"dasdsa"));
$a = array_merge_recursive($a, array('date' => array('msg3'=>'tel')));
print_r($a);
Array
(
[date] => Array
(
[msg1] => asdasd
[msg2] => dasdsa
[msg3] => tel
)
)