PHP Classes

Div PHP Matrix Library: Define matrices with dynamic cell calculations

Recommend this page to a friend!
  Info   Example   Videos   View files Files   Install with Composer Install with Composer   Download Download   Reputation   Support forum   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2024-02-02 (8 months ago) RSS 2.0 feedNot enough user ratingsTotal: 66 All time: 10,365 This week: 71Up
Version License PHP version Categories
divengine-matrix 1.3.0GNU General Publi...8Tools, Data types, Math, PHP 8
Description 

Author

This package provides functionality for defining and manipulating matrices, offering various output formats.

It accepts a bidimensional array to initialize the matrix with cell values.

This package offers flexibility in matrix manipulation, enabling dynamic calculations and providing diverse output options for ease of integration into various applications.
Key features include:


* Matrix operations

- Add or remove rows and columns.

- Set values for specific matrix positions.

- Populate matrix values dynamically using custom functions.


* Dynamic Recalculation

- Matrix cells support dynamic calculations based on other cells, allowing changes to trigger a recalculation of dependent cells automatically, akin to Excel's behavior.


* Output Formats:

- Display matrix values in multiple formats, such as plain text, CSV, XML, JSON, HTML table, Markdown, YAML, and SQL insert statements.

Innovation Award
PHP Programming Innovation award nominee
January 2024
Number 6
A matrix data type can store many values, like a table.

Several types of applications need to perform operations on data stored in a matrix.

This package can perform several operations in a matrix and output the resulting matrix in several formats like CSV, XML, JSON, HTML table, Markdown, YAML, and SQL.

This way, this package can be used by applications that need to convert matrix data to a format that other applications can use.

Manuel Lemos
Picture of Rafa Rodriguez
  Performance   Level  
Name: Rafa Rodriguez <contact>
Classes: 7 packages by
Country: Suriname Suriname
Age: 38
All time rank: 17201 in Suriname Suriname
Week rank: 164 Up1 in Suriname Suriname Equal
Innovation award
Innovation award
Nominee: 4x

Example

<?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;


Details

Div PHP Matrix 1.3

This dynamic matrix manipulation class in PHP goes beyond conventional operations, offering dynamic calculations and diverse output formats for versatile applications.

It introduces a layer of dynamic logic where cells execute functions, allowing for flexible backend logic. The true power lies in crafting robust backend logic, akin to spreadsheet functionalities tailored for web development. Automatic recalculation is notable, but its strength lies in facilitating complex business logic.

Consider it as a tool for architecting backend logic using a spreadsheet-like paradigm. Dynamic calculations create interconnected matrices, triggering logical events across cells and matrices seamlessly.

The library empowers developers to create responsive systems, adapting to user interactions. Exporting data in various formats, including XML and JSON, extends its utility in web development.

A cell's ability to execute dynamic logic is a game-changer, allowing intricate and adaptable behavior defined by a function. Activating or deactivating cells opens possibilities to tailor business logic on-the-fly.

In essence, Div PHP Matrix not only facilitates dynamic recalculations but empowers adaptive backend logic. Its fluid response, driven by cell activation and deactivation, showcases potential in crafting dynamic applications.

The library seamlessly integrates with other divengine/* projects (div, ways, nodes, ajaxmap & orm), forming a comprehensive and non-obtrusive toolkit for PHP developers, enhancing dynamic backend capabilities.

Requirements

  • PHP 8.0 or higher

Installation

composer require divengine/matrix

Documentation

https://divengine.org/

Examples

See "examples" folder.


Videos (1)  
  • Div PHP Matrix - Basic features
  Files folder image Files (22)  
File Role Description
Files folder imageexamples (11 files, 2 directories)
Files folder imagesrc (1 file)
Accessible without login Plain text file composer.json Data Auxiliary data
Accessible without login Plain text file LICENSE Lic. License text
Accessible without login Plain text file README.md Doc. Read me

  Files folder image Files (22)  /  examples  
File Role Description
Files folder imagedata (1 file)
Files folder imagehandlers (6 files)
  Accessible without login Plain text file calculations.php Example Example script
  Accessible without login Plain text file cells.php Example Example script
  Accessible without login Plain text file create.php Example Example script
  Plain text file custom.php Class Class source
  Accessible without login Plain text file edit.php Example Example script
  Plain text file extends.php Class Class source
  Accessible without login Plain text file grouping.php Example Example script
  Accessible without login Plain text file router.php Example Example script
  Plain text file router_oop.php Class Class source
  Accessible without login Plain text file simple.php Example Example script
  Accessible without login Plain text file worksheet.php Example Example script

  Files folder image Files (22)  /  examples  /  data  
File Role Description
  Accessible without login Plain text file matrix.json Data Auxiliary data

  Files folder image Files (22)  /  examples  /  handlers  
File Role Description
  Accessible without login Plain text file 404.php Aux. Auxiliary script
  Accessible without login Plain text file about.php Aux. Auxiliary script
  Accessible without login Plain text file admin.php Aux. Auxiliary script
  Accessible without login Plain text file home.php Aux. Auxiliary script
  Accessible without login Plain text file log.php Aux. Auxiliary script
  Accessible without login Plain text file login.php Aux. Auxiliary script

  Files folder image Files (22)  /  src  
File Role Description
  Plain text file matrix.php Class Class source

The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page.
Install with Composer Install with Composer
 Version Control Unique User Downloads Download Rankings  
 100%
Total:66
This week:0
All time:10,365
This week:71Up