How do you solve this ... by studying the scanning of zero-base arrays .
You cannot use $index<=$length as a condition.
Use $index<$length , instead.
<?php for($d=0;$d<sizeof($datearray);$d++){ ?> ^^^^^
And yes, there is a better way:
<?php foreach($datearray as $date){ ?> <?php echo $date;?> <?php } ?>
and even better: (PHP endfor / endforeach )
<?php foreach($datearray as $date): ?> <?php echo $date;?> <?php endforeach; ?>
source share