PHP for loop help needed
Posted: Tue Feb 10, 2009 6:38 pm
Hello, here is what I am trying to accomplish. I have variables being passed from a form to a different page for processing. Say these are the names of the variables in the form... variable101, variable102, variable103... variable150. I am trying to process these 50 different variables by calling them in a for loop, like so...
for ( $i=101, $i<151, $i++ ) {
echo "variable$i contains $_POST['variable{$i}']";
}
would hopefully output....
variable101 contains blahblah1 variable102 contains blahblah2 variable103 contains blahblah3 ....
But it is not working, its not trying to call variable101, variable102, variable103.
The data in the form is there if you explicitly call $variable101, $variable102... I just cannot accomplish the task using the $i, can anyone help me please? Thanks.
for ( $i=101, $i<151, $i++ ) {
echo "variable$i contains $_POST['variable{$i}']";
}
would hopefully output....
variable101 contains blahblah1 variable102 contains blahblah2 variable103 contains blahblah3 ....
But it is not working, its not trying to call variable101, variable102, variable103.
The data in the form is there if you explicitly call $variable101, $variable102... I just cannot accomplish the task using the $i, can anyone help me please? Thanks.