Reputation: 39
$firstarray = array(
'name'=>$name,
'address'=>$address
);
$_SESSION['info'] = $firstarray;
$secondarray = array(
'postcode'=>$postcode,
'email'=>$email
);
$_SESSION['info'] = $secondarray;
Hi guys, how do I add the array into session info without overwrite its value which are already inside? I want the session info contain the value of firstarray and second array all together.
Upvotes: 0
Views: 74
Reputation: 160833
Use array_merge:
$_SESSION['info'] = array_merge($_SESSION['info'], $secondarray);
Upvotes: 1