PHPackages                             arifkhan06091992/php\_arithmetic\_expression\_calculator - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. arifkhan06091992/php\_arithmetic\_expression\_calculator

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

arifkhan06091992/php\_arithmetic\_expression\_calculator
========================================================

This Package can be use for check syntax of a arithmetic expression, convert Infix Expression To Postfix Expression, c

02PHP

Since Feb 5Pushed 6y ago1 watchersCompare

[ Source](https://github.com/arifkhan06091992/php_arithmetic_expression_calculator)[ Packagist](https://packagist.org/packages/arifkhan06091992/php_arithmetic_expression_calculator)[ RSS](/packages/arifkhan06091992-php-arithmetic-expression-calculator/feed)WikiDiscussions master Synced today

READMEChangelogDependenciesVersions (1)Used By (0)

PHP Arithmetic Expression Calculator
====================================

[](#php-arithmetic-expression-calculator)

A simple library to be use for check syntax of a arithmetic expression, convert Infix Expression To Postfix Expression and calculate a arithmetic expression.

Installation
------------

[](#installation)

You can install it using [Composer](https://getcomposer.org).

```
composer require arifkhan06091992/php_arithmetic_expression_calculator
```

### Dependencies

[](#dependencies)

- PHP 5.6+

Basic usage
-----------

[](#basic-usage)

### Check Syntax Analyzer

[](#check-syntax-analyzer)

You can check artihmatic expression syntax using this package.

```
$expression = '2 * ( 3 - 2 ) / ( 4 * 5 - 4 ) + 6';
$cal = new ArithmeticExpressionCalculator($expression,1);
$cal->syntaxAnalyzer() // True

$expression = '+ 2 * ( 3 - 2 ) / ( 4 * 5 - 4 ) + 6';
$cal = new ArithmeticExpressionCalculator($expression,1);
$cal->syntaxAnalyzer() // False

$expression = 'a * ( b - a ) / ( c * d - c ) + e';
$cal = new ArithmeticExpressionCalculator($expression,2);
$cal->syntaxAnalyzer() // True

$expression = 'operand1 * ( operand2 - operand1 ) / ( operand3 * operand4 - operand3 ) + operand5';
$cal = new ArithmeticExpressionCalculator($expression,1);
$cal->syntaxAnalyzer() // True
```

### Convert Infix Expression To Postfix Expression

[](#convert-infix-expression-to-postfix-expression)

You can check artihmatic expression syntax using this package.

```
$expression = '2 * ( 3 - 2 ) / ( 4 * 5 - 4 ) + 6';
$cal = new ArithmeticExpressionCalculator($expression,1);
$cal->convertInfixExpressionToPostfixExpression()
// 2 3 2 - * 4 5 * 4 - / 6 +

$expression = '+ 2 * ( 3 - 2 ) / ( 4 * 5 - 4 ) + 6';
$cal = new ArithmeticExpressionCalculator($expression,1);
$cal->convertInfixExpressionToPostfixExpression() // Error

$expression = 'a * ( b - a ) / ( c * d - c ) + e';
$cal = new ArithmeticExpressionCalculator($expression,2);
$cal->convertInfixExpressionToPostfixExpression() // True

$expression = 'operand1 * ( operand2 - operand1 ) / ( operand3 * operand4 - operand3 ) + operand5';
$cal = new ArithmeticExpressionCalculator($expression,1);
$cal->convertInfixExpressionToPostfixExpression() // True
```

### Calculate a Arithmetic Expression

[](#calculate-a-arithmetic-expression)

You can check calculate a arithmetic expression using this package.

```
$expression = '2 * ( 3 - 2 ) / ( 4 * 5 - 4 ) + 6';
$cal = new ArithmeticExpressionCalculator($expression,1);
$cal->calculateExpression()
// 6.125

$expression = '+ 2 * ( 3 - 2 ) / ( 4 * 5 - 4 ) + 6';
$cal = new ArithmeticExpressionCalculator($expression,1);
$cal->calculateExpression() // Error

$expression = 'operand1 * ( operand2 - operand1 ) / ( operand3 * operand4 - operand3 ) + operand5';
$cal = new ArithmeticExpressionCalculator($expression,2, [
        'operand1' => 2,
        'operand2' => 3,
        'operand3' => 4,
        'operand4' => 5,
        'operand5' => 6
    ]);
$cal->calculateExpression() // 6.125
```

###  Health Score

16

—

LowBetter than 5% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity2

Limited adoption so far

Community4

Small or concentrated contributor base

Maturity34

Early-stage or recently created project

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/b3be07871abe0bf419acf2c94b5a00e3f2a3b4e57bde975dbcd91bff95107ebc?d=identicon)[arifkhan06091992](/maintainers/arifkhan06091992)

### Embed Badge

![Health badge](/badges/arifkhan06091992-php-arithmetic-expression-calculator/health.svg)

```
[![Health](https://phpackages.com/badges/arifkhan06091992-php-arithmetic-expression-calculator/health.svg)](https://phpackages.com/packages/arifkhan06091992-php-arithmetic-expression-calculator)
```

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
