Communities for your favorite technologies. Explore all Collectives
Stack Overflow for Teams is now called Stack Internal. Bring the best of human thought and AI automation together at your work.
Bring the best of human thought and AI automation together at your work. Learn more
Find centralized, trusted content and collaborate around the technologies you use most.
Stack Internal
Knowledge at work
Bring the best of human thought and AI automation together at your work.
I would like to loop 5 arrays in post. What should be the right code to display: $_POST["fp0"] $_POST["fp1"] .. $_POST["fp5"] in a loop?
$x = 0; while($x <= 5) { $fp = ${'_POST["fp'.$x.'"]'}; echo $fp.'<br>'; $x++; }
echo $_POST['fp' . $i]
0 to 5 are six numbers, so you want to loop 6 elements in an array,
this is what you want
for( $i = 0; $i <= 5; $i++ ){ echo $_POST['fp'.$i]."<br>\n"; }
Add a comment
Try this:
$x = 0; while($x <= 5) { $fp = $_POST["fp$x"]; echo $fp.'<br>'; $x++; }
You can do it simply by for loop, you form must POST values for
for
POST
fp0, fp1 .... fp5
for($i = 0; $i < 5; $i++) { $fp = $_POST['fp'.$i]; echo $fp . "<br>"; }
Required, but never shown
By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.
Start asking to get answers
Find the answer to your question by asking.
Explore related questions
See similar questions with these tags.
echo $_POST['fp' . $i]