Solarpitch Posted August 15, 2008 Share Posted August 15, 2008 Hey guys, I have the following array $_POST['rows'] that stores a series of values when a form is submitted. How can I transfer this into an array. So basically I want to store it as $_SESSION['rows']. Below is an example of what I tried, not sure if its right. <?php foreach ($_POST['rows'] as $row) { echo $row[value]; } //So I want to now store this array as a session, so I tried.. $_SESSION['rows'][] = $_POST['rows']; //Dont think this is right tho ?> Quote Link to comment https://forums.phpfreaks.com/topic/119852-solved-hoe-to-assign-an-array-to-a-session/ Share on other sites More sharing options...
kenrbnsn Posted August 15, 2008 Share Posted August 15, 2008 Just do this: <?php session_start(); $_SESSION['rows'] = $_POST['rows']'; ?> Ken Quote Link to comment https://forums.phpfreaks.com/topic/119852-solved-hoe-to-assign-an-array-to-a-session/#findComment-617445 Share on other sites More sharing options...
DeanWhitehouse Posted August 15, 2008 Share Posted August 15, 2008 you need session start at the top of the page , and i think this $_SESSION['rows'][] = $_POST['rows']; should be $_SESSION['rows'] = $_POST['rows']; edit (kenrbnsn got there first) Quote Link to comment https://forums.phpfreaks.com/topic/119852-solved-hoe-to-assign-an-array-to-a-session/#findComment-617447 Share on other sites More sharing options...
Solarpitch Posted August 15, 2008 Author Share Posted August 15, 2008 Thats grand, thanks lads. I already had the session_start(); so it was just a matter of using.. $_SESSION['rows'] = $_POST['rows']; instead of $_SESSION['rows'][] = $_POST['rows']; Quote Link to comment https://forums.phpfreaks.com/topic/119852-solved-hoe-to-assign-an-array-to-a-session/#findComment-617454 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.