more looping stuff and playing with colors for Stephen, generalized header bits a touch

cat-town
Dan Buch 14 years ago
parent 3970fead8f
commit 9dab7bf8d7

@ -0,0 +1,35 @@
<?php
function mkheader($title, $bgcolor) {
?>
<!DOCTYPE html>
<html>
<head>
<title><?php echo $title; ?></title>
<style type='text/css'>
/*<![CDATA[*/
body {
color: #222;
background-color: #eee;
font-family: monospace;
}
pre {
border: 1px dashed #777;
color: #000;
background-color: <?php echo $bgcolor ?>;
padding: 5px;
margin: 10px;
}
/*]]>*/
</style>
</head>
<?php
}
?>

@ -1,22 +1,34 @@
<!DOCTYPE html> <?php
<html>
<head> require_once("_head.php");
<title>looping!</title>
<style type="text/css">
/*<![CDATA[*/ $BGCOLOR_CHOICES = array(
'pink',
pre { 'purple',
border: 1px dashed #777; 'blue',
color: #222; 'red',
background: #fefefe; 'green',
padding: 5px; 'gray',
margin: 10px; 'white',
} 'orange'
);
$bgcolor = $_GET['bgcolor'];
if (! $bgcolor) {
$bgcolor = $BGCOLOR_CHOICES[array_rand($BGCOLOR_CHOICES, 1)];
}
mkheader("looping!", $bgcolor);
?>
/*]]>*/
</style>
</head>
<body> <body>
<p>Using &lt;pre&gt; bgcolor = <?php echo $bgcolor; ?></p>
<!-- ======================================================= -->
<pre><?php <pre><?php
$c = 0; $c = 0;
@ -28,6 +40,7 @@
?></pre> ?></pre>
<!-- ======================================================= -->
<pre><?php <pre><?php
$myname = "Fred"; $myname = "Fred";
@ -49,6 +62,7 @@
?></pre> ?></pre>
<!-- ======================================================= -->
<pre><?php <pre><?php
$c = 6; $c = 6;
@ -59,6 +73,7 @@
?></pre> ?></pre>
<!-- ======================================================= -->
<pre><?php <pre><?php
for ($i = 0; $i < 5; $i++) { for ($i = 0; $i < 5; $i++) {
@ -68,6 +83,7 @@
?></pre> ?></pre>
<!-- ======================================================= -->
<pre><?php <pre><?php
$menu = array( $menu = array(
@ -88,5 +104,26 @@
?></pre> ?></pre>
<!-- ======================================================= -->
<pre><?php
$array = array(
"1st" => "My House",
"2nd" => "My Car",
"3rd" => "My Lab"
);
foreach ($array as $key => $value) {
if ($value == "My Lab") {
$array[$key] = $value = "My Laboratory";
}
print "$key holds the value $value \n";
}
?></pre>
</body> </body>
</html> </html>

Loading…
Cancel
Save