This is maybe an obvious question but I can not resolve it so I prefer to ask it.
I have an array ($fechas[]) with consecutive dates, from startdate to enddate.
I want to show each value twice in this table.
for ($i=0; $i < $sesion ; $i++)
{
$d = date( "d/m/Y", strtotime($fechas[$i]) );
echo "<tr><td>FECHA: ".$d."</td></tr>";
}
?>
$sesion is always multiple of 2.
So if $sesion is 4 and $fechas has two dates, the table has to show:
FECHA: echo(date("d/m/Y", strtotime($fechas[0])))
FECHA: echo(date("d/m/Y", strtotime($fechas[0])))
FECHA: echo(date("d/m/Y", strtotime($fechas[1])))
FECHA: echo(date("d/m/Y", strtotime($fechas[1])))
$fechas is something like this:
Array ( [0] => 2014-02-03 [1] => 2014-02-04 )
I want to show each cell of $fechas[] each two iterations of the loop.
Do you refer to this:
for ($i=0; $i < $sesion ; $i++) { ?>
<tr><td>FECHA: <? echo(date("d/m/Y", strtotime($fechas[floor($i/2)]))) ?></td></tr>
<? } ?>
floor($i/2) keeps same value on each two consecutive loops
Try this
for ($i=0; $i < $sesion ; $i++) { ?>
<? $date = date("d/m/Y", strtotime($fechas[$i]));?>
<tr><td>FECHA: <? echo $date ?></td></tr>
<tr><td>FECHA: <? echo $date ?></td></tr>
<? } ?>