PHPackages                             jsgm/odds-php - 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. jsgm/odds-php

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

jsgm/odds-php
=============

v2.01(1mo ago)622MITPHPPHP &gt;=8.1CI passing

Since Apr 10Pushed 1mo ago1 watchersCompare

[ Source](https://github.com/jsgm/odds-php)[ Packagist](https://packagist.org/packages/jsgm/odds-php)[ RSS](/packages/jsgm-odds-php/feed)WikiDiscussions master Synced 1w ago

READMEChangelog (1)Dependencies (1)Versions (3)Used By (0)

[![Building](https://github.com/jsgm/odds-php/actions/workflows/phplint.yml/badge.svg)](https://github.com/jsgm/odds-php/actions/workflows/phplint.yml/badge.svg) [![License](https://camo.githubusercontent.com/4277272ff0df4f5f84f9e6e248638b9ca55d11f1bec72cb5d88ae066d02684d8/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f6a73676d2f6f6464732d706870)](https://camo.githubusercontent.com/4277272ff0df4f5f84f9e6e248638b9ca55d11f1bec72cb5d88ae066d02684d8/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f6a73676d2f6f6464732d706870)

OddsPHP
=======

[](#oddsphp)

OddsPHP is a lightweight library to easily work with odds conversions and calculations.

With a few lines of code you'll be able to:

- Odds conversions between **decimal, fractional, american** and **implied probability**.
- Calculate **payouts** and **overrounds**.
- Getting the **real probabilities**.
- **Surebets** calculations.

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

[](#installation)

The recommended way to install **odds-php** is via [Composer](https://getcomposer.org):

```
composer require jsgm/odds-php
```

Alternatively, you can clone the repository directly:

```
git clone https://github.com/jsgm/odds-php.git
```

1. Working with odds
--------------------

[](#1-working-with-odds)

### 1.1 Convert odds between formats

[](#11-convert-odds-between-formats)

Convert odds between different types of formats. If the given odd is not valid it will throw an exception.

```
// Converting decimal to fractional.
$odd = new  Odds();
echo  $odd->set('decimal', 5.50)->get('fractional'); // "string" 9/2

// Converting fractionalto moneyline.
$odd = new  Odds();
echo  $odd->set('fractional', '11/25')->get('moneyline'); // "float" -227

// Converting fractional to implied probability.
$odd = new  Odds();
echo  $odd->set('fractional', '44/100')->get('implied'); // "string" 69.44
```

**Allowed formats are:**

- 'decimal'
- 'fractional'
- 'implied'
- 'moneyline'
- 'hongkong'
- 'malay'
- 'indonesian'

### 1.2 Reduce to the lowest term a fractional odd

[](#12-reduce-to-the-lowest-term-a-fractional-odd)

Reduce a fraction with the **reduce()** method or just pass any fraction and it will automatically reduce it for you as shown here:

```
print $odd->set('fractional', '44/100')->reduce(); // "string" 11/25
print $odd->set('fractional', '44/100')->get('fractional'); // "string" 11/25
```

Bookmarkers always use the simplest form of a fraction and you should do too.

### 1.3 Set decimal and percentage precision

[](#13-set-decimal-and-percentage-precision)

By default, all decimal odds and percentages will be returned with 2 decimals. You can modify that by using:

```
$odd = new Odds();
$odd->set_precision(1);
$odd->set('decimal', 1.29)->get('decimal'); // "float" 1.3

$odd->set_precision(2);
$odd->set('decimal', '1,800.00')->get('decimal'); // "float" 1800.00
```

2. Calculating payouts and overrounds
-------------------------------------

[](#2-calculating-payouts-and-overrounds)

Now that you know how to convert odds in a few seconds, OddsPHP also includes a few tools to help you doing extra calculations easily.

The payouts are the amount of money given back to the user who won a bet whereas the overround is the profit that the bookie takes. If you don't know this concepts, check [this website](https://caanberry.com/understanding-the-over-round-in-betting-markets/) where you can find a bunch of examples.

Let's assume we have the following market with the given odds:

Home TeamDrawAway Team4.453.401.90This group of odds will be defined in our code like this (Rembember that you also can mix different odd formats):

```
$group = [['decimal', 4.45], ['decimal', 3.40], ['decimal', 1.90]];

// Use the 'Payouts' class and don't forget to require it at the beginning of your code.
$payout = new Payouts($group);
```

The **payout** is calculated by simply subtracting the overround to 100. This can be done using the following method:

```
print  $payout->get_payout(); // "float" 95.49
```

Getting the **implied probabilities** for each odd. This probabilities are not real since the bookmarker comission is added. You may need them if you want to calculate by yourself.

```
// 100 / (decimal odd) = implied probability
var_dump($payout->get_implied_probabilities()); // [22.47, 29.41, 52.63]
```

If we sum all of them we will have a remaining percentage, that's the **overround**.

```
// array_sum([22.47, 29.41, 52.63]) = 104.51
// 104.51 - 100 = Overround
print  array_sum($payout->get_implied_probabilities()); // "float" 104.51
print  $payout->get_overround(); // "float" 4.51
```

We can also get the **real probabilities** for a group of odds:

```
// Formula: 100 / [Odd * (Payout / 100)] = real probability
$payout->get_real_probabilities(); // [23.53, 30.8, 55.12]
```

We may get at some point a negative result for the overround. That means we have found a surebet!

3. Surebets
-----------

[](#3-surebets)

We can check for a surebet given a odds set. Remember that you will need at least 2 different odds bookmarkers. The next example is a real surebet case. As you might have noticed the odds are provided by different bookies.

[![Surebet example](https://camo.githubusercontent.com/ba09a43b552921d344328deb34f01861e0594dff989910114d261ff2d3e80d82/68747470733a2f2f65732e737572656265742e636f6d2f6573732f77696b692f6368656c7365616d752e706e67)](https://camo.githubusercontent.com/ba09a43b552921d344328deb34f01861e0594dff989910114d261ff2d3e80d82/68747470733a2f2f65732e737572656265742e636f6d2f6573732f77696b692f6368656c7365616d752e706e67)

```
// The 'Payouts' class has to be required in order to use 'Surebets'.
$surebet = new Surebets([['decimal', 2.3], ['decimal', 3.3], ['decimal', 3.97]]);
if($surebet->is_surebet()){
	print 'Surebet found! :)';
	// '.($surebet->profit()).'% profit!';
}else{
	print 'Sorry! :( No surebet found!';
}
```

###  Health Score

39

—

LowBetter than 84% of packages

Maintenance89

Actively maintained with recent releases

Popularity9

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity43

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

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.

###  Release Activity

Cadence

Every ~2 days

Total

2

Last Release

57d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/2b091a3ad37e333b247aea5dbf955966cac396a29155c77990487936e6b6db3c?d=identicon)[jsgm](/maintainers/jsgm)

---

Top Contributors

[![jsgm](https://avatars.githubusercontent.com/u/34169065?v=4)](https://github.com/jsgm "jsgm (31 commits)")

---

Tags

bettingoddsodds-conversionsodds-formatsurebets

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/jsgm-odds-php/health.svg)

```
[![Health](https://phpackages.com/badges/jsgm-odds-php/health.svg)](https://phpackages.com/packages/jsgm-odds-php)
```

###  Alternatives

[inovector/mixpost

Self-hosted social media management software.

3.3k5.7k2](/packages/inovector-mixpost)[alexwenzel/nova-dependency-container

A Laravel Nova 4 form container for grouping fields that depend on other field values.

461.1M2](/packages/alexwenzel-nova-dependency-container)[producer/producer

Tools for releasing library packages; supports Git, Mercurial, Github, Gitlab, and Bitbucket.

10419.2k3](/packages/producer-producer)

PHPackages © 2026

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