4 2
4 2
php
// Define a 2D array (matrix)
$rows = 3;
$cols = 4;
$matrix = array();
// Fill the matrix with values (you can also take user input here)
for ($i = 0; $i < $rows; $i++) {
for ($j = 0; $j < $cols; $j++) {
$matrix[$i][$j] = $i * $j; // Example: fill with the product of i and j
}
}