Hi Folks,
Back again with a new problem. I think it's a simple one, but it escapes me:
There are sixty-four buildings numbered building one through building sixty-four. I want to "visit" each of the buildings one time, selecting the building to be visited in random order, but I do not want to visit building six at all. The code accomplishes that seemingly perfectly, except that after reaching the loop limit, I'm echoing one last time, with the building number blank. Here's the code:
Here are the last three lines of what the above code produces:PHP Code:$buildings = range (1, 64);
$building_index = 1;
shuffle ($buildings);
while ($building_index < 65) {
if ($buildings[$building_index] !== 6 ){
echo "Building " . $buildings[$building_index] . " All hail Caesar!<br />";
}
$building_index ++;
}
Building 4 All hail Caesar!
Building 56 All hail Caesar!
Building All hail Caesar!
What am I missing?
A.



Reply With Quote

Bookmarks