2010-12-30 02:43:03 +00:00
|
|
|
<!DOCTYPE html>
|
|
|
|
<html>
|
|
|
|
<head>
|
|
|
|
<title>looping!</title>
|
|
|
|
<style type="text/css">
|
|
|
|
/*<![CDATA[*/
|
2010-12-30 02:30:13 +00:00
|
|
|
|
2010-12-30 02:43:03 +00:00
|
|
|
pre {
|
|
|
|
border: 1px dashed #777;
|
|
|
|
color: #222;
|
|
|
|
background: #fefefe;
|
|
|
|
padding: 5px;
|
|
|
|
margin: 10px;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*]]>*/
|
|
|
|
</style>
|
|
|
|
</head>
|
|
|
|
<body>
|
|
|
|
<pre><?php
|
|
|
|
|
|
|
|
$c = 0;
|
|
|
|
|
|
|
|
while ($c < 5) {
|
|
|
|
print $c++ . "\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
?></pre>
|
|
|
|
|
|
|
|
|
|
|
|
<pre><?php
|
|
|
|
|
|
|
|
$myname = "Fred";
|
|
|
|
$i = 0;
|
|
|
|
|
|
|
|
while ($myname != "Rumpelstiltskin") {
|
|
|
|
print $i++ . ": ";
|
|
|
|
|
|
|
|
if ($myname == "Fred") {
|
|
|
|
$myname = "Leslie";
|
|
|
|
} else {
|
|
|
|
$myname = "Rumpelstiltskin";
|
|
|
|
}
|
|
|
|
print "$myname\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
print "How did you know?\n";
|
|
|
|
|
|
|
|
?></pre>
|
|
|
|
|
|
|
|
|
|
|
|
<pre><?php
|
|
|
|
$c = 6;
|
|
|
|
|
|
|
|
do {
|
|
|
|
print "Hi\n";
|
|
|
|
} while ($c < 5);
|
|
|
|
|
|
|
|
?></pre>
|
|
|
|
|
|
|
|
|
|
|
|
<pre><?php
|
|
|
|
|
|
|
|
for ($i = 0; $i < 5; $i++) {
|
|
|
|
print "$i\n";
|
|
|
|
}
|
2010-12-30 02:30:13 +00:00
|
|
|
|
2010-12-30 02:43:03 +00:00
|
|
|
?></pre>
|
2010-12-30 02:30:13 +00:00
|
|
|
|
|
|
|
|
2010-12-30 02:43:03 +00:00
|
|
|
<pre><?php
|
2010-12-30 02:30:13 +00:00
|
|
|
|
2010-12-30 02:43:03 +00:00
|
|
|
$menu = array(
|
|
|
|
"Toast and Jam",
|
|
|
|
"Bacon and Eggs",
|
|
|
|
"Homefries",
|
|
|
|
"Skillet",
|
|
|
|
"Milk and Cereal"
|
|
|
|
);
|
2010-12-30 02:30:13 +00:00
|
|
|
|
2010-12-30 02:43:03 +00:00
|
|
|
$count = count($menu);
|
2010-12-30 02:30:13 +00:00
|
|
|
|
2010-12-30 02:43:03 +00:00
|
|
|
for ($i = 0; $i < $count; $i++) {
|
|
|
|
$j = $i + 1;
|
2010-12-30 02:30:13 +00:00
|
|
|
|
2010-12-30 02:43:03 +00:00
|
|
|
print "$j. {$menu[$i]}\n";
|
2010-12-30 02:30:13 +00:00
|
|
|
}
|
|
|
|
|
2010-12-30 02:43:03 +00:00
|
|
|
?></pre>
|
2010-12-30 02:30:13 +00:00
|
|
|
|
2010-12-30 02:43:03 +00:00
|
|
|
</body>
|
|
|
|
</html>
|