How to retrieve a dynamically created $_POST variable

Hi all I need to retrieve a dynamically created field it should be named something like 0field, 1field, etc... It is created dynamically so I don't know how many fields are needed but I do know that they are created by using something like: $i."field", how should I go to retrieve it, since I cant seem to make it work no matter what I try?
The $i variable is a counter so I should be able to retrieve it inside a for as I'm trying but... No use...

A sample of code would be very appreciated...

Bellow is the code that I tried to make do, but ...

Thanks in advance to anyone who could crack it.
for($i=0;$i<$cont2;$i++){
$_SESSION['$x'] = $_POST['($i."field)"'];
}

Open in new window

doRodrigoLecturerAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

lharrispvCommented:
try this

 for($i=0;$i<$cont2;$i++){
$_SESSION['$x'] = $_POST[$i ."field"];
}
 
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
doRodrigoLecturerAuthor Commented:
Thanks that was really it, even though I had tried it already, I probably had something misspelled. Congrats, thanks and here are the points...
0
BrianMMCommented:
I suspect you need to make your for loop generate hidden inputs and pass them that way.
0
PMI ACP® Project Management

Prepare for the PMI Agile Certified Practitioner (PMI-ACP)® exam, which formally recognizes your knowledge of agile principles and your skill with agile techniques.

doRodrigoLecturerAuthor Commented:
Actually no it the previous solution worked, I had misspelled something because I'm sure I had tried it already... Anyway thanks...
0
lharrispvCommented:
Actually the problem was righ here...

The normal syntax for $_post is $_post["blah"].  The name of the field is in quotes because it is a string.    Also there are not prentices in it.

You had:
$_POST['($i."field)"'];
It contains prentices, and an extra single qutoe.  Basically you want it to wind up being the same as above.  $i . "field" is equivilent to strings such as 1field, 2field etc.

Does that make sense?

0
doRodrigoLecturerAuthor Commented:
Completely, I understood it from what you wrote, I had already tried it but had misspelled somewhat, but it was great the prompt feedback. Thanks again...
0
lharrispvCommented:
no problem.  Glad I could help.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.