With the aid of PHP online manual you will create a multidimensional array that contains the measurements, in inches, for several boxes that a shipping company might use to determine the volume of a box and display the volume (length * width * depth) of each box. Save the document as BoxArray.php
To create the array use this format-
$box = array
(
array(1,2,3),
array(4,5,6),
array(7,8,9)
);
you can also take user variables, but here i am taking array with pre-defined values.
TO find the volume u can use following concept-
for($i = 0; $i < count($box); $i++) {
echo $box[$i][$0]*$box[$i][$1]*$box[$i][$2] . "\n";
FINAL PROGRAM-
<?php
$box = array
(
array(1,2,3),
array(4,5,6),
array(7,8,9)
);
for($i = 0; $i < count($box); $i++) {
echo $box[$i][$0]*$box[$i][$1]*$box[$i][$2] . "\n";
?>
Get Answers For Free
Most questions answered within 1 hours.