0
$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.

1
  • 3
    create two dimensional array like $_SESSION['info']['first'] and $_SESSION['info']['second'] Commented Mar 3, 2014 at 7:59

1 Answer 1

1

Use array_merge:

$_SESSION['info'] = array_merge($_SESSION['info'], $secondarray);
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.