I have a form with dynamic fields. with inputs with names like this:
<input type="hidden" name="nome_prod1" value="Shampoo Hidratante Dazen Elegance">
<input data-theme="b" value="0" name="qtd1" type="text" id="1"/>
<input type="hidden" name="nome_prod2" value="Shampoo Hidratante Dazen Elegance">
<input data-theme="b" value="0" name="qtd2" type="text" id="1"/>
Each one with its value, the problem is the time to show this because I did not want to show so little save in the bank the fields that have quantity 0
.
I used the command:
foreach( $_POST as $nome_campo => $valor)
{
$comando = "$" . $nome_campo . "='" . $valor . "';";
eval($comando);
}
But he brought all the inputs, I tried to try not to show the ones with qtd = 0
but the problem is in searching for the variable I put a $i
counter inside foreach
, then the name of the variable qtd
I tried to call it like this:
if ($qtd{$i} == 0 ) {}
But it did not work, how do I do that fetch a dynamic variable?
$qtd1
$qtd2
$qtd3