I’m coming with a small piece of code that contains a sample of double variable usage. Let’s take we have a script that transmits lots of parameters, named activ1, activ2, activ3… activn. How should we work with them?
A simple solution is pasted below.
for ($i=0; $i<10; $i++)
{
$varname=”aktiv”.$i;if (isset($$varname))
{
// Do anything you want here
}
}
You create variable names in a loop and then use double variables. This helps you to check how many parameters were sent, what are their values and anything else related to a big number of parameters that could be transmitted to a script. It is a common practice to use such a variables with checkboxes and this one will be the easiest way to sort them out.