Hello, I have a form that captures some data, the variables that capture this data are:
$parentesco1 = $_POST['parentesco1'];
$edad1 = $_POST['edad1'];
$NivelAcademico1 = $_POST['NivelAcademico1'];
$ocupacion1 = $_POST['ocupacion1'];
$salario1 = $_POST['salario1'];
But it is a table so the variables are 6 times more alone than with their numbers increased
$parentesco2 = $_POST['parentesco2'];
$edad2 = $_POST['edad2'];
$NivelAcademico2 = $_POST['NivelAcademico2'];
$ocupacion2 = $_POST['ocupacion2'];
$salario2 = $_POST['salario2'];
And so until I get to 6, my question is, how can I print this data in a for using the variable of for as a counter in the variable, that is to say that the number of the variable increases based on the variable of the FOR
for ($i=1; $i <=6 ; $i++) {
$imprimir = "$parentesco"."$i";
echo "$imprimir";
};
This is what I tried to do but I do not know how I could do it
var_dump($_POST)
give me this:
array (size=29)
'parentesco1' => string 'padre' (length=5)
'edad1' => string '35' (length=2)
'NivelAcademico1' => string 'bachillerato' (length=12)
'ocupacion1' => string 'Vendedor' (length=8)
'salario1' => string '50' (length=2)
'parentesco2' => string 'madre' (length=5)
'edad2' => string '58' (length=2)
'anio2' => string 'Comerciante' (length=11)
'salario2' => string '150' (length=3)
'parentesco3' => string 'hermana' (length=7)
'edad3' => string '18' (length=2)
'NivelAcademico3' => string 'bachillerato' (length=12)
'anio3' => string 'Maquilera' (length=9)
'salario3' => string '200' (length=3)
'parentesco4' => string 'tio' (length=3)
'NivelAcademico4' => string 'bachillerato' (length=12)
'anio4' => string 'Vendedora' (length=9)
'salario4' => string '350' (length=3)
'parentesco5' => string 'abuela' (length=6)
'edad5' => string '52' (length=2)
'NivelAcademico5' => string 'basico' (length=6)
'anio5' => string 'NO' (length=2)
'salario5' => string '0' (length=1)
'parentesco6' => string 'hermano' (length=7)
'edad6' => string '18' (length=2)
'NivelAcademico6' => string 'no' (length=2)
'anio6' => string 'NO' (length=2)
'salario6' => string '0' (length=1)
'form10' => string '' (length=0)