save array as a session?
Posted: Mon Sep 17, 2007 5:03 pm
hello, I am trying to store several input values into an array as a session. here is the code i have used:
it works and the var_dump
looks like this:
array(7) { [0]=> string(6) "pierre" [1]=> string(7) "hobstra" [2]=> string(8) "20030809" [3]=> string(1) "m" [4]=> string(4) "null" [5]=> string(32) "these are all my medical issues." [6]=> string(70) "blah blah blah blah blah blah blah....that\'s all she ever says to me." }
which seems to be good to me, I don't know why there is curly braces, but I have never tried this before either. I'm just learning.
then I try to call the one of the values like this:
it doesn't work, I get NULL.
can anyone tell me what I'm doing wrong? what would be the best way to do this?
Thanks.
Code: Select all
$student_info= array($fn, $ln, $dob, $sex, $school, $medical, $notes) ;
$_SESSION['stud_info']=$student_info ;looks like this:
array(7) { [0]=> string(6) "pierre" [1]=> string(7) "hobstra" [2]=> string(8) "20030809" [3]=> string(1) "m" [4]=> string(4) "null" [5]=> string(32) "these are all my medical issues." [6]=> string(70) "blah blah blah blah blah blah blah....that\'s all she ever says to me." }
which seems to be good to me, I don't know why there is curly braces, but I have never tried this before either. I'm just learning.
then I try to call the one of the values like this:
Code: Select all
var_dump ($_SESSION['stud_info[1]']);it doesn't work, I get NULL.
can anyone tell me what I'm doing wrong? what would be the best way to do this?
Thanks.