PHP Classes

File: examples/cells.php

Recommend this page to a friend!
  Classes of Rafa Rodriguez   Div PHP Matrix Library   examples/cells.php   Download  
File: examples/cells.php
Role: Example script
Content type: text/plain
Description: Example script
Class: Div PHP Matrix Library
Define matrices with dynamic cell calculations
Author: By
Last change:
Date: 5 months ago
Size: 654 bytes
 

Contents

Class file image Download
<?php

include __DIR__ . '/../src/matrix.php';

use
divengine\matrix;

$m = new matrix([
    [
1, 2, 3],
    [
4, 5, 6],
    [
7, 8, 9]
]);

// echo $m->get(1, 1);
echo $m->{1.1};
echo
"\n";

// echo $m->{0.2};
echo $m->{.2};
echo
"\n";

// echo $m->{2.2};
echo $m->{-1.2};
echo
"\n";

for (
$i = 0; $i < 3; $i++)
    for (
$j = 0; $j < 3; $j++)
        echo
$m->{$i + ($j / 10)} . " ";
echo
"\n";

for (
$i = 0; $i < 3; $i++)
        for (
$j = 0; $j < 3; $j++)
            echo
$m->{($i + ($j / 10) + 1) * -1} . " ";
echo
"\n";

for (
$i = 0; $i < 3; $i++)
    for (
$j = 0; $j < 3; $j++)
        echo
$m->{"$i.$j"} . " ";

echo
"\n";

$m->{0.0} = 10;
echo
$m;