Advertisement
mauricemuteti

boxArray.php

Nov 19th, 2020
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <title>Multidimensional Associative Array PHP</title>
  5. </head>
  6. <body>
  7. <?php
  8. $boxArray = array(
  9. array('Small Box' , '12' , '10', '2.5' ),
  10. array('Medium Box' , '30' , '20', '4' ),
  11. array('Large Box' , '60' , '40', '11.5' ),
  12. );
  13. echo '<table border="1">';
  14. echo '<tr><th>Boxes</th><th>Length</th><th>Width</th><th>Depth</th></tr>';
  15. foreach( $boxArray as $boxArray1 )
  16. {
  17. echo '<tr>';
  18. foreach( $boxArray1 as $key )
  19. {
  20. echo '<td>'.$key.'</td>';
  21. }
  22. echo '</tr>';
  23. }
  24. echo '</table><br/>';
  25. //volume of small box
  26. echo "Volume of Small box :".($boxArray[0][1] * $boxArray[0][2] * $boxArray[0][3])."<br/>";
  27. //volume of medium box
  28. echo "Volume of Medium box :".($boxArray[1][1] * $boxArray[1][2] * $boxArray[1][3])."<br/>";
  29. //volume of large box
  30. echo "Volume of Large box :".($boxArray[2][1] * $boxArray[2][2] * $boxArray[2][3])."<br/>";
  31. ?>
  32. </body>
  33. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement