From 361de8c5870f5e946443bf9376cd735211ba1187 Mon Sep 17 00:00:00 2001 From: btn15001 Date: Sun, 26 Feb 2017 21:18:24 -0500 Subject: [PATCH] php file --- index.php | 64 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 index.php diff --git a/index.php b/index.php new file mode 100644 index 0000000..b26ae3a --- /dev/null +++ b/index.php @@ -0,0 +1,64 @@ + + + + + +

+ 'with', + 'tomato' => 'without', + 'onions' => 'with'); + + $pizza = array('cheese' => 'with', + 'pepperoni' => 'without', + 'mushrooms' => 'with'); + + $burger = array('cheese' => 'without', + 'bread' => 'without', + 'bacon' => 'with', + 'onions' => 'without', + 'lettuce' => 'with', + 'mayo' => 'with', + 'pickles' => 'with'); + + // Looping through an array using "for". + // First, let's get the length of the array! + $length = count($food); + + // Remember, arrays in PHP are zero-based: + for ($i = 0; $i < $length; $i++) { + echo $food[$i] . '
'; + } + + echo '

I want my salad:
'; + + // Loop through an associative array using "foreach": + foreach ($salad as $ingredient=>$include) { + echo $include . ' ' . $ingredient . '
'; + } + + + // Create your own array here and loop + // through it using foreach! + echo '

I want my pizza:
'; + + foreach ($pizza as $ingredient=>$include) { + echo $include . ' ' . $ingredient . '
'; + } + + echo '

I want my burger:
'; + + foreach ($burger as $ingredient=>$include) { + echo $include . ' ' . $ingredient . '
'; + } + + ?> +

+ + + \ No newline at end of file