fezzik Posted November 10, 2006 Share Posted November 10, 2006 I need help with correctly rewriting the below script as a session variable, primarily the correct way to write $numbers[$id] as a session array:if (isset($numbers[$id])) { $numbers[$id] += $another_count;} else { $numbers[$id] = $another_count;} foreach($numbers as $key => $val) echo $key . ' : ' . $val . "<br />\r\n";Thank you for any assistance! Fezzik Link to comment https://forums.phpfreaks.com/topic/26863-rewrite-as-a-session-variable/ Share on other sites More sharing options...
Orio Posted November 10, 2006 Share Posted November 10, 2006 What do you exctly mean? Change the variable to a session variable?Instead of $numbers[$id] write $_SEESION[$id]. Dont forget to run session_start() at the begining.Orio. Link to comment https://forums.phpfreaks.com/topic/26863-rewrite-as-a-session-variable/#findComment-122857 Share on other sites More sharing options...
fezzik Posted November 10, 2006 Author Share Posted November 10, 2006 Thanks for the response. I believe that $_SESSION[$id] is not correct. I need to keep the $numbers[$id] as an array. Link to comment https://forums.phpfreaks.com/topic/26863-rewrite-as-a-session-variable/#findComment-122871 Share on other sites More sharing options...
toplay Posted November 10, 2006 Share Posted November 10, 2006 $_SESSION['numbers'][$i] = ... Link to comment https://forums.phpfreaks.com/topic/26863-rewrite-as-a-session-variable/#findComment-122873 Share on other sites More sharing options...
fezzik Posted November 10, 2006 Author Share Posted November 10, 2006 Thanks! I just discovered this!Cheers,Fezzik Link to comment https://forums.phpfreaks.com/topic/26863-rewrite-as-a-session-variable/#findComment-122874 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.