DWPD-3.1: Write PHP Script using two dimensional arrays such as addition of two 2×2 matrices.

array addition, two dimensional array
Lab # 3

FUNCTIONS

3. Write PHP Script using two dimensional arrays such as addition of two 2×2 matrices.

Lab-3-1-array.php

<?php
$a=array(array(6,2),array(11,3));
$b=array(array(5,3),array(4,3));

echo "Matrix Addition <br>";

for($i=0;$i<2;$i++)
{
for($j=0;$j<2;$j++)
{
echo $a[$i][$j]+$b[$i][$j]." ";
}
echo "<br>";
}
?>


Output

lab 3-1 output
two-dimensional array addition | Practical Server


Happy Coding 🙂

Leave a comment