We help IT Professionals succeed at work.

Check out our new AWS podcast with Certified Expert, Phil Phillips! Listen to "How to Execute a Seamless AWS Migration" on EE or on your favorite podcast platform. Listen Now


How to retrieve a dynamically created $_POST variable

doRodrigo asked
Medium Priority
Last Modified: 2013-12-13
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.
$_SESSION['$x'] = $_POST['($i."field)"'];

Open in new window

Watch Question

Unlock this solution and get a sample of our free trial.
(No credit card required)


Thanks that was really it, even though I had tried it already, I probably had something misspelled. Congrats, thanks and here are the points...

I suspect you need to make your for loop generate hidden inputs and pass them that way.


Actually no it the previous solution worked, I had misspelled something because I'm sure I had tried it already... Anyway thanks...
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:
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?



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...
no problem.  Glad I could help.
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.


Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.