Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
php file
  • Loading branch information
btn15001 committed Feb 27, 2017
1 parent 4c6edb7 commit 361de8c
Showing 1 changed file with 64 additions and 0 deletions.
64 changes: 64 additions & 0 deletions index.php
@@ -0,0 +1,64 @@
<html>


<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);

?>
<body>
<p>
<?php
$food = array('pizza', 'salad', 'burger');
$salad = array('lettuce' => '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] . '<br />';
}

echo '<br /><br />I want my salad:<br />';

// Loop through an associative array using "foreach":
foreach ($salad as $ingredient=>$include) {
echo $include . ' ' . $ingredient . '<br />';
}


// Create your own array here and loop
// through it using foreach!
echo '<br /><br />I want my pizza:<br />';

foreach ($pizza as $ingredient=>$include) {
echo $include . ' ' . $ingredient . '<br />';
}

echo '<br /><br />I want my burger:<br />';

foreach ($burger as $ingredient=>$include) {
echo $include . ' ' . $ingredient . '<br />';
}

?>
</p>

</body>
</html>

0 comments on commit 361de8c

Please sign in to comment.