Ver Mensaje Individual
  #1 (permalink)  
Antiguo 23/06/2009, 09:35
Ari0n
 
Fecha de Ingreso: enero-2009
Mensajes: 24
Antigüedad: 16 años, 1 mes
Puntos: 0
Procesar formulario con inputs arrays multidimensionales

Bueno, tengo este formulario:

Código HTML:
<form action="<?php echo $_SERVER['PHP_SELF'] ?>" method="post">
<input type="text" value="2000" 	name="pagos[valor1][1]" />
<input type="text" value="0001" 	name="pagos[codigo2][1]" />
<input type="text" value="44" 		name="pagos[dias3][1]" />
<input type="radio" value="si"		name="pagos[pg1][1]" />
<input type="radio" value="no"		name="pagos[pg1][1]" />
<br /><br />
<input type="text" value="6000" 	name="pagos[valor4][2]" />
<input type="text" value="0003" 	name="pagos[codigo5][2]" />
<input type="text" value="41" 		name="pagos[dias6][2]" />
<input type="radio" value="si"		name="pagos[pg2][2]" />
<input type="radio" value="no"		name="pagos[pg2][2]" />
<br /><br />
<input type="text" value="36000" 	name="pagos[valor7][3]" />
<input type="text" value="0006" 	name="pagos[codigo8][3]" />
<input type="text" value="36" 		name="pagos[dias9][3]" />
<input type="radio" value="si"		name="pagos[pg3][3]" />
<input type="radio" value="no"		name="pagos[pg3][3]" />
<input type="submit" value="enviar" />
</form> 
lo proceso asi:

Código PHP:
<?php

    
if($_POST['pagos']){
        
        foreach (
$_POST['pagos'] as $set)
        {
         foreach (
$set as $id => $value)
          {
            echo 
"Propiedad: $key, Indice: $id, Valor: $value".'<br>';
          }
        }  
        
    }

?>
y el resultado es esto:

Propiedad: , Indice: 1, Valor: 2000
Propiedad: , Indice: 1, Valor: 0001
Propiedad: , Indice: 1, Valor: 44
Propiedad: , Indice: 1, Valor: si
Propiedad: , Indice: 2, Valor: 6000
Propiedad: , Indice: 2, Valor: 0003
Propiedad: , Indice: 2, Valor: 41
Propiedad: , Indice: 2, Valor: si
Propiedad: , Indice: 3, Valor: 36000
Propiedad: , Indice: 3, Valor: 0006
Propiedad: , Indice: 3, Valor: 36
Propiedad: , Indice: 3, Valor: no

Hasta aqui, todo bien, ahora necesito que cada indice, 1,2,3, me ejecute un script, osea que los valores que tiene el indice 1 me los procese, y asi sucesivamente con los otros.

Gracias.