i was wondering if there is any way that i can reference to an existing variable outside the loop
I currently have 50 variables that i am getting of a form they contain a "nr_" part and after that it is counting from 1 to 50 and i also have the $_POST variables of that. I now want to pass that into a for loop to get form input fields for each variable with a set value ($nr_1-50).
this is my current state:
for ($x = 1; $x <= 50; $x++) {
echo "<tr><input type='number' name='nr_" . $x . "' value='" . $nr_1 . "'></tr>";
}
Maybe you can help me
Thank you in advance
EDIT:
i solved the problem as follows:
//created an array
$sticker_nr = array();
//inserted the $_POST values with a digit counting to 50 ($x)
for($x = 1; $x <= 50; $x++){
$sticker_nr[$x] = $_POST[$x.'_nr'];
}
//now i am able to output the array values in a loop
for ($x = 1; $x <= 50; $x++) {
echo "<input type='number' name='".$x."_nr' value='". $sticker_nr[$x] ."'
>";
}
//Thank you again for the response