•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the PHP section within the Web Development category of DaniWeb, a massive community of 397,751 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,585 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our PHP advertiser: Lunarpages PHP Web Hosting
Views: 2984 | Replies: 4
![]() |
•
•
Join Date: Oct 2004
Location: San Francisco, CA
Posts: 338
Reputation:
Rep Power: 4
Solved Threads: 1
I need to load a value from a recently posted page...
[php]for ($i=0; $i<10; $i++)
{
$_SESSION['someVar'][$i] = $_POST['someVar'][$i]
$_SESSION['anotherVar'][$i] = $_POST['anotherVar'][$i]
$_SESSION['yetAnotherVar'][$i] = $_POST['yetAnotherVar'][$i]
}[/php]
now the session part works just fine, but the $_POST part just blows up on me! How can I fix this? I want to keep the $_POST there, because I know I can just do $someVar[$i] and that will work but it's not what I want to do. I have seen a foreach loop and thought about that. But, would that keep all the variables tied together with the same index? I really dont want to use a foreach loop if I dont have to, but if thats what I need to use, then so be it.
Thanks!
[php]for ($i=0; $i<10; $i++)
{
$_SESSION['someVar'][$i] = $_POST['someVar'][$i]
$_SESSION['anotherVar'][$i] = $_POST['anotherVar'][$i]
$_SESSION['yetAnotherVar'][$i] = $_POST['yetAnotherVar'][$i]
}[/php]
now the session part works just fine, but the $_POST part just blows up on me! How can I fix this? I want to keep the $_POST there, because I know I can just do $someVar[$i] and that will work but it's not what I want to do. I have seen a foreach loop and thought about that. But, would that keep all the variables tied together with the same index? I really dont want to use a foreach loop if I dont have to, but if thats what I need to use, then so be it.
Thanks!
•
•
Join Date: Jun 2005
Location: Kansas City, Missouri, USA
Posts: 344
Reputation:
Rep Power: 4
Solved Threads: 4
•
•
•
•
Originally Posted by paradox814
[php]$_SESSION['someVar'][$i] = $_POST['someVar'][$i][/php]
Whether it is an array or not, you can just do this:
[PHP]
$_SESSION['someVar'] = $_POST['someVar'];
[/PHP]It does not matter whether 'someVar' is an array or not--the session var will still receive the value.
•
•
Join Date: Jan 2005
Location: Sheffield, UK
Posts: 294
Reputation:
Rep Power: 4
Solved Threads: 6
How about this?[PHP] $_SESSION['someVar'][$i] = $_POST['someVar'.$i] [/PHP]In this case, your form variables are someVar1, someVar2,...
Ecommerce-Web-Store.com Building Your e-Business.
•
•
Join Date: Jun 2005
Location: Kansas City, Missouri, USA
Posts: 344
Reputation:
Rep Power: 4
Solved Threads: 4
val542, your reply makes no sense. The define() function does not even apply to this scenario.
![]() |
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
•
•
•
•
DaniWeb PHP Marketplace
Similar Threads
- Arrays within $_POST[]? (PHP)
- PHP help in creating profile thingy (PHP)
- Problems with uising arrays and $_POST variables (PHP)
- Comparing elements of two seperate Arrays (PHP)
Other Threads in the PHP Forum
- Previous Thread: htpasswd and htaccess config
- Next Thread: Get error of MSSQl-proc


Linear Mode