Ver Mensaje Individual
  #2 (permalink)  
Antiguo 23/07/2009, 05:52
Avatar de gjx2
gjx2
 
Fecha de Ingreso: agosto-2008
Ubicación: R.D
Mensajes: 1.153
Antigüedad: 15 años, 8 meses
Puntos: 139
Respuesta: mensaje Undefined offset al introducir variable en argumento de funcion

1- Esto no es valido

Código PHP:
$diap=sumaDia('$fecha',$i); ## Linea 14.

/*

No estas mandando el valor de la variable fecha . 
las comillas simple no interpretan las variables.

*/ 
Esto deveria funcionar.

Código PHP:

<?php

function sumaDia($fecha,$i)
{    list(
$year,$mon,$day) = explode('-',$fecha);
return 
date('Y-m-d',mktime(0,0,0,$mon,$day+$i,$year));
}


$fecha "2009-03-21";

for(
$a=0;$a<10;$a++){
echo 
"<br>";
echo 
sumaDia($fecha,$a);
}