PHP code example of lisachenko / native-php-matrix
1. Go to this page and download the library: Download lisachenko/native-php-matrix library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
$a = new Matrix([[1, 2, 3]]);
$b = new Matrix([[4], [5], [6]]);
$product = $a * $b;
var_dump($product->toArray()); // [[32]] — a 1×3 times a 3×1 gives a 1×1
$m = new Matrix([[1, 2], [3, 4]]);
var_dump((array) $m); // [[1, 2], [3, 4]] — the rows, not the object's internals
echo (string) $m; // [1, 2]
// [3, 4]
var_dump((bool) $m); // bool(true) — a valid matrix is never empty by construction