- Code: Select all
`matrix_a[0][0] matrix_a[1][0] matrix_a[2][0] matrix_a[3][0]`

matrix_a[0][1] matrix_a[1][1] matrix_a[2][1] matrix_a[3][1]

matrix_a[0][2] matrix_a[1][2] matrix_a[2][2] matrix_a[3][2]

...and so on. Then you'd have a second, similar grid of <input>s for the n x k matrix.

With me so far? Since m, n, and k are unknown (I'm assuming), you'd just have PHP generate the <input> grid with a nested for() loop, something like this:

- Code: Select all
`<form method="GET" action="script.php">`

<?php

$m_max = 3; // the number of columns in the m x n matrix

$n_max = 2; // the number of rows for m x n, cols for n x k

$k_max = 4; // you get the picture..

// generate the m x n <input> grid

for($m = 0; $m < $m_max; $m++) {

for($n = 0; $n < $n_max; $n++) {

echo '<input type="text" name="matrix_a[' . $m . '][' . $n . ']">';

}

echo "<br/>\n";

}

echo "<br/>\n";

// generate the n x k grid

for($n = 0; $n < $n_max; $n++) {

for($k = 0; $k < $k_max; $k++) {

echo '<input type="text" name="matrix_b[' . $n . '][' . $k . ']">';

}

echo "<br/>\n";

}

?>

<input type="submit">

</form>

There, now you have two nice grids of text input fields. The first (m x n) will dump into a multidimensional array called $matrix_a, and the second (n x k) into $matrix_b.

Now's where it gets interesting. You have to do some math. Either you can read up on matrix multiplication and write your own implementation, or (and this is what I recommend), you can just use someone else's. PEAR has a good Math component, or you could try the PHP Math Library Project, or, if all else fails, just Google it. Have fun!