Hi everybody, I need help with something I’m trying to do and I’m pretty sure I’m not actually calling this the right way, I will try my best to explain it but if you have any questions, please feel free to ask to make sure it’s clear. Thanks.
Basically, I’m trying to print a variable value coming out from 2 variables.
Let’s say the variable I’m trying to print is called $value5, quite simple, but $value5 is not defined, it comes from a form that has multiple dynamic checkbox fields ($value1, $value2, $value3, etc.), the number of checkbox can vary from one form to another and I can know, depending on the opened form, how many of them there are (Form A has 3 checkboxes, Form B has 5 checkboxes, etc.)
Once the form is submitted, I want to dynamically recreate the values, by knowing the number of checkboxes, I can do a little while loop and I need to recreate the variable in the loop so I can save them. Something like this;
$maxcheckboxes = 4;
$loop = 1;
while ($loop < $maxcheckboxes)
{
print("value$loop <br />");
$loop++;
}
That would output this;
value1
value2
value3
value4
But actually, that is not I want, I want the value of the checkbox to be printed when checked, if the value is always ‘item_checked’ when checked, and that I check 1, 2 and 4, I want this to be printed;
item_checked
item_checked
item_checked
So basically, I want this;
$value1 -> item_checked
$value2 -> item_checked
$value3 ->
$value4 -> item_checked
And not this;
$value1 -> value1
$value2 -> value2
$value3 -> value3
$value4 -> value4