hazy Posted April 28, 2006 Share Posted April 28, 2006 I've search the forums... google... and finally my eyes are burning and I am way to tired so I am hoping someone on here can see what I am missing. Basically I am trying to load a session array with another array which was populated by database information. For some reason I can not get it to work. For some reason the data entered the first time threw the loop seems to 'disappear' after it loops threw the second time. i.e. If I echo $_SESSION['userinfo']['array'][0] on the first time threw the loop it will show the proper data... the second time threw and it throws an UNDEFINED INDEX: 0 at me. Anyone have any ideas?! [code]$a = 0;while ($Array1[$a]){ $_SESSION['userinfo']['array'] = array($a => $Array1[$a]); echo $_SESSION['userinfo']['array'][0]; $a = $a + 1;}[/code] Link to comment https://forums.phpfreaks.com/topic/8598-session-array/ Share on other sites More sharing options...
toplay Posted April 28, 2006 Share Posted April 28, 2006 [code]// Example of setting the session valuesfor ($i = 0, cnt=count($Array1); $i < $cnt; $i++) { // [] creates a new index automatically $_SESSION['userinfo']['array'][] = $Array1[$i]; // or just use: $_SESSION['userinfo'][] = ...}// An example of how to display the session valuesfor ($i = 0, cnt=count($_SESSION['userinfo']['array']); $i < $cnt; $i++) { echo "Data $i: ", $_SESSION['userinfo']['array'][$i], '<br/>';}[/code] Link to comment https://forums.phpfreaks.com/topic/8598-session-array/#findComment-31544 Share on other sites More sharing options...
hazy Posted April 29, 2006 Author Share Posted April 29, 2006 [!--quoteo(post=369453:date=Apr 27 2006, 11:39 PM:name=toplay)--][div class=\'quotetop\']QUOTE(toplay @ Apr 27 2006, 11:39 PM) [snapback]369453[/snapback][/div][div class=\'quotemain\'][!--quotec--][code]// Example of setting the session valuesfor ($i = 0, cnt=count($Array1); $i < $cnt; $i++) { // [] creates a new index automatically $_SESSION['userinfo']['array'][] = $Array1[$i]; // or just use: $_SESSION['userinfo'][] = ...}// An example of how to display the session valuesfor ($i = 0, cnt=count($_SESSION['userinfo']['array']); $i < $cnt; $i++) { echo "Data $i: ", $_SESSION['userinfo']['array'][$i], '<br/>';}[/code][/quote]Thank you!! :) Link to comment https://forums.phpfreaks.com/topic/8598-session-array/#findComment-31866 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.