I am doing a homework assignment and am having trouble finding out how to code the problem. I have performed multiple searches on Google but found nothing on how to use a foreach loop using the same keys with multiple values in a multidimensional array.
I have two questions:
How can I figure out how to do two use a foreach loop and loop through the arrays in this code and print out the values to test the foreach loop?
How can I print out the code that is in the html below the php code within the <td> tags.
Hereās a foreach loop that I thought would work but it doesnāt print out the code correctly to test values.
<?php
foreach ($items as $title=>$value) {`
echo $items." ā ".$value."<br />";
}
?php>
<?php
$items = array(
array("title" => "Guardians of the Galaxy Vol. 2", 'type' => "blue-ray","price" => 19.99),
array("title" => "Wonder Woman 2017", 'type' => "4K","price" => 24.99),
array("title" => "Spider-Man: Homecoming", 'type' => "blue-ray","price" => 22.99),
array("title" => "War For The Planet Of The Apes", 'type' => "4K","price" => 19.99),
array("title" => "Baby Driver", 'type' => "blue-ray","price" => 24.99),
array("title" => "Atomic Blonde", 'type' => "4K","price" => 24.99),
array("title" => "Moana", 'type' => "blue-ray","price" => 15.99),
array("title" => "Alien: Covenant", 'type' => "blue-ray","price" => 21.96),
array("title" => "Despicable Me 3", 'type' => "4K","price" => 24.99),
array("title" => "Firefly Complete Series", 'type' => "blue-ray","price" => 20.99),
);
?>
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Available Movie Titles</title>
<link href="assets/bootstrap.min.css" rel="stylesheet" type="text/css">
<style>
body {
margin-top:50px;
overflow:scroll;
}
</style>
<div class="col-md-8 col-md-offset-2">
<table class="table table-striped table-hover">
<thead>
<tr>
<th>Title</th>
<th>Blue Ray</th>
<th>4K</th>
<th>Price</th>
</tr>
</thead>
<tbody>
<!--start of row that you need to include for each item in the array-->
<tr>
<td>title goes here</td>
<td>if type is equal to blue-ray, then show a yes</td>
<td>if type is equal to 4K, then show a yes</td>
<td>price goes here</td>
</tr>
<!--end of row that you need to include for each item in the array-->
</tbody>
</table>
</div>