{"id":49323997,"url":"https://github.com/jsgm/odds-php","last_synced_at":"2026-04-26T19:02:41.715Z","repository":{"id":172793733,"uuid":"264715076","full_name":"jsgm/odds-php","owner":"jsgm","description":"OddsPHP is a lightweight library to easily work with odds conversions and calculations.","archived":false,"fork":false,"pushed_at":"2026-04-10T20:46:07.000Z","size":46,"stargazers_count":6,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2026-04-10T22:22:50.223Z","etag":null,"topics":["betting","odds","odds-conversions","odds-format","surebets"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jsgm.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2020-05-17T16:57:42.000Z","updated_at":"2026-04-10T20:46:12.000Z","dependencies_parsed_at":null,"dependency_job_id":"4e320334-d497-4796-b93a-2bc614342d94","html_url":"https://github.com/jsgm/odds-php","commit_stats":null,"previous_names":["scrapebet/oddsphp","jsgm/odds-php"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/jsgm/odds-php","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jsgm%2Fodds-php","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jsgm%2Fodds-php/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jsgm%2Fodds-php/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jsgm%2Fodds-php/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jsgm","download_url":"https://codeload.github.com/jsgm/odds-php/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jsgm%2Fodds-php/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32308882,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-26T17:23:19.671Z","status":"ssl_error","status_checked_at":"2026-04-26T17:23:19.195Z","response_time":129,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["betting","odds","odds-conversions","odds-format","surebets"],"created_at":"2026-04-26T19:02:41.136Z","updated_at":"2026-04-26T19:02:41.692Z","avatar_url":"https://github.com/jsgm.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"![Building](https://github.com/jsgm/odds-php/actions/workflows/phplint.yml/badge.svg) ![License](https://img.shields.io/github/license/jsgm/odds-php)\n\n# OddsPHP\nOddsPHP is a lightweight library to easily work with odds conversions and calculations.\n\nWith a few lines of code you'll be able to:\n - Odds conversions between **decimal, fractional, american** and **implied probability**.\n - Calculate **payouts** and **overrounds**.\n - Getting the **real probabilities**.\n - **Surebets** calculations.\n\n## Installation\nThe recommended way to install **odds-php** is via [Composer](https://getcomposer.org):\n```bash\ncomposer require jsgm/odds-php\n```\n\nAlternatively, you can clone the repository directly:\n```bash\ngit clone https://github.com/jsgm/odds-php.git\n```\n\n## 1. Working with odds\n### 1.1 Convert odds between formats\nConvert odds between different types of formats. If the given odd is not valid it will throw an exception.\n```php\n// Converting decimal to fractional.\n$odd = new  Odds();\necho  $odd-\u003eset('decimal', 5.50)-\u003eget('fractional'); // \"string\" 9/2\n\n// Converting fractionalto moneyline.\n$odd = new  Odds();\necho  $odd-\u003eset('fractional', '11/25')-\u003eget('moneyline'); // \"float\" -227\n\n// Converting fractional to implied probability.\n$odd = new  Odds();\necho  $odd-\u003eset('fractional', '44/100')-\u003eget('implied'); // \"string\" 69.44\n```\n**Allowed formats are:**\n\n - 'decimal'\n - 'fractional'\n - 'implied'\n - 'moneyline'\n - 'hongkong'\n - 'malay'\n - 'indonesian'\n\n### 1.2 Reduce to the lowest term a fractional odd\nReduce a fraction with the **reduce()** method or just pass any fraction and it will automatically reduce it for you as shown here:\n```php\nprint $odd-\u003eset('fractional', '44/100')-\u003ereduce(); // \"string\" 11/25\nprint $odd-\u003eset('fractional', '44/100')-\u003eget('fractional'); // \"string\" 11/25\n```\n\nBookmarkers always use the simplest form of a fraction and you should do too.\n\n### 1.3 Set decimal and percentage precision\nBy default, all decimal odds and percentages will be returned with 2 decimals. You can modify that by using:\n```php\n$odd = new Odds();\n$odd-\u003eset_precision(1);\n$odd-\u003eset('decimal', 1.29)-\u003eget('decimal'); // \"float\" 1.3\n\n\n$odd-\u003eset_precision(2);\n$odd-\u003eset('decimal', '1,800.00')-\u003eget('decimal'); // \"float\" 1800.00\n```\n\n## 2. Calculating payouts and overrounds\nNow that you know how to convert odds in a few seconds, OddsPHP also includes a few tools to help you doing extra calculations easily.\n\nThe 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.\n\nLet's assume we have the following market with the given odds:\n| Home Team | Draw | Away Team |\n|--|--|--|\n| 4.45 | 3.40 | 1.90 |\n\nThis group of odds will be defined in our code like this (Rembember that you also can mix different odd formats):\n```php\n$group = [['decimal', 4.45], ['decimal', 3.40], ['decimal', 1.90]];\n\n// Use the 'Payouts' class and don't forget to require it at the beginning of your code.\n$payout = new Payouts($group);\n```\n\nThe **payout** is calculated by simply subtracting the overround to 100. This can be done using the following method:\n```php\nprint  $payout-\u003eget_payout(); // \"float\" 95.49\n```\n\nGetting 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.\n```php\n// 100 / (decimal odd) = implied probability\nvar_dump($payout-\u003eget_implied_probabilities()); // [22.47, 29.41, 52.63]\n```\n\nIf we sum all of them we will have a remaining percentage, that's the **overround**.\n```php\n// array_sum([22.47, 29.41, 52.63]) = 104.51\n// 104.51 - 100 = Overround\nprint  array_sum($payout-\u003eget_implied_probabilities()); // \"float\" 104.51\nprint  $payout-\u003eget_overround(); // \"float\" 4.51\n```\n\nWe can also get the **real probabilities** for a group of odds:\n```php\n// Formula: 100 / [Odd * (Payout / 100)] = real probability\n$payout-\u003eget_real_probabilities(); // [23.53, 30.8, 55.12]\n```\n\nWe may get at some point a negative result for the overround. That means we have found a surebet!\n\n## 3. Surebets\nWe 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.\n\n![Surebet example](https://es.surebet.com/ess/wiki/chelseamu.png)\n\n```php\n// The 'Payouts' class has to be required in order to use 'Surebets'.\n$surebet = new Surebets([['decimal', 2.3], ['decimal', 3.3], ['decimal', 3.97]]);\nif($surebet-\u003eis_surebet()){\n\tprint 'Surebet found! :)';\n\t// '.($surebet-\u003eprofit()).'% profit!';\n}else{\n\tprint 'Sorry! :( No surebet found!';\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjsgm%2Fodds-php","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjsgm%2Fodds-php","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjsgm%2Fodds-php/lists"}