- Php
- Features
- Autoload
- Class Reflection
- Magic Methods
- Exceptions
- Late Static Binding
- Type Hinting
- SPL
- PHPUNIT
- PHAR
- Composer
- Guzzle
- Carbon
- Faker
- Math ♣
- Requests
- Design Patterns
- Singleton Pattern
- Observer Pattern
- Strategy Pattern
- Registry
- Symfony
- Routes
- Annotations
- Flex
- Controllers
- Doctrine
- Templating
- Versions
- Php7.4
- Php8.0
- Security
- Filter Input
- Remote Code Injection
- Sql Injection
- Session Fixation
- File Uploads
- Cross Site Scripting
- Spoofed Forms
- CSRF
- Session Hijacking
- Modern Php
- Composer
- Slim Framework
- Autoloader
- Package
- Releases
- Generators
- Dependency Injection
- Middleware
- Create Framework
- App
- Http Foundation
- Front Controller
- Routing
- Render Controller
- Resolver
- SoC
- Frameworks
- Symfony V5
- Laravel V8
- Laminas V3
- Codeigniter V4
Math
MathPHP is a powerful modern math library for PHP.
/**
* composer require markrogoyski/math-php
*/
require_once __DIR__ . '/vendor/autoload.php';
use MathPHP\Algebra;
use MathPHP\Arithmetic;
use MathPHP\Functions\Map;
use MathPHP\LinearAlgebra\Matrix;
use MathPHP\LinearAlgebra\MatrixFactory;
// Greatest common divisor (GCD)
echo $gcd = Algebra::gcd(8, 12) . "\n"; // 4
// Sum of digits
echo $digit_sum = Arithmetic::digitSum(99) . "\n"; // 18
// Map functions
$x = [10, 10, 10, 10];
$y = [1, 2, 5, 10];
$products = Map\Multi::multiply($x, $y);
echo implode(", ", $products) . "\n"; // 10, 20, 50, 100
// Matrix
$matrix = [
[1, 2, 3],
[4, 5, 6],
[7, 8, 9],
];
$A = MatrixFactory::create($matrix);
$row = $A->getRow(2);
echo implode(", ", $row) . "\n"; // 7, 8, 9
Last update: 61 days ago