Ver Mensaje Individual
  #11 (permalink)  
Antiguo 21/08/2011, 19:47
Avatar de hackcrack
hackcrack
 
Fecha de Ingreso: abril-2011
Mensajes: 331
Antigüedad: 13 años, 1 mes
Puntos: 9
Respuesta: Foreach, array para una funcion

Lo probe asi pero siempre me marca el error :S

Cita:
<?
if ( !empty($_POST['aceptar']) ) {
$vector = array('abc','def','ghi');
foreach ($vector as $letra) {
if ( !empty($_POST[$$letra]) ) $$letra = $_POST[$$letra];
if ( empty($$letra) ) $error[$$letra] = 'Es obligatorio completar el campo';
echo $error[$$letra];
}
}
?>


<form method="post" action="">
<input name="abc" /><br/>
<input name="def" /><br/>
<input name="ghi" /><br/>
<input type="submit" name="aceptar" />
</form>