Obviously I can't use the JS var i in my PHP code. I tried breaking it off from the PHP code by putting it outside of the tags but it didn't work.
<?php
$list = array();
$list[0] = "January";
$list[1] = "February";
$list[2] = "March";
$list[3] = "April";
$list[4] = "May";
?>
<script type="text/javascript">
for (var i = 0; i < <?php echo sizeof($list);?>; i++) {
alert("<?php echo $list[i];?>");
}
</script>