I have this code on the HTML side:
<form action="testx.php" method="post"> <input type="hidden" name="block-1" value="001"/> <input type="hidden" name="block-2" value="012"/> <input type="hidden" name="block-3" value="002"/> <input type="hidden" name="block-4" value="005"/> <input type="hidden" name="block-5" value="008"/> <input type="hidden" name="title" value="title goes here"/> <input type="hidden" name="code" value="018439128484"/> <input type="submit" value="Finish!" class="submit-btn" /> </form>
and I have this Foreach loop on the PHP side:
<?php $i=0; foreach($_POST as $name => $value) { echo $i . " - " . $name . ": " . $value . "<br>"; $i++; } ?>
Unfortunately, this Foreach loop handles all inputs ... how to make this loop ONLY run inputs with the name "block-X"?
I tried to try like this, but failed:
$i=0; $x = 'block-'.$i+1; foreach($_POST[$x] as $name => $value)
he says: Warning: invalid argument provided by foreach ()
thanks!
source share