Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html>
- <head>
- <title>Multidimensional Associative Array PHP</title>
- </head>
- <body>
- <?php
- $boxArray = array(
- array('Small Box' , '12' , '10', '2.5' ),
- array('Medium Box' , '30' , '20', '4' ),
- array('Large Box' , '60' , '40', '11.5' ),
- );
- echo '<table border="1">';
- echo '<tr><th>Boxes</th><th>Length</th><th>Width</th><th>Depth</th></tr>';
- foreach( $boxArray as $boxArray1 )
- {
- echo '<tr>';
- foreach( $boxArray1 as $key )
- {
- echo '<td>'.$key.'</td>';
- }
- echo '</tr>';
- }
- echo '</table><br/>';
- //volume of small box
- echo "Volume of Small box :".($boxArray[0][1] * $boxArray[0][2] * $boxArray[0][3])."<br/>";
- //volume of medium box
- echo "Volume of Medium box :".($boxArray[1][1] * $boxArray[1][2] * $boxArray[1][3])."<br/>";
- //volume of large box
- echo "Volume of Large box :".($boxArray[2][1] * $boxArray[2][2] * $boxArray[2][3])."<br/>";
- ?>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement