...

View Full Version : simple example I dont understand:



joliett89
08-23-2011, 07:39 PM
<?php

$months = array("January", "February", "March", "April", "May");

$a = 0;

$b = count($months);

while($a < $b) {
echo $months[$a], "<br />";
++$a;
}
?>


Elements in the array are assigned a number 0, 1, 2 etc... I did not think about that. I think I get it now. Thank you.

djm0219
08-24-2011, 01:10 PM
A simpler way of looking at/doing it (IMO):



$months = array("January", "February", "March", "April", "May");

foreach ($months as $month) {
print $month . '<br /';
}



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum