PHPackages                             cloned/luckybox - 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. cloned/luckybox

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

cloned/luckybox
===============

A library to pick up the one with a specified probability from some items.

v0.9.0(12y ago)157.5k31MITPHPPHP &gt;=5.3.0

Since Oct 20Pushed 12y ago5 watchersCompare

[ Source](https://github.com/cloned/luckybox)[ Packagist](https://packagist.org/packages/cloned/luckybox)[ Docs](https://github.com/cloned/luckybox)[ RSS](/packages/cloned-luckybox/feed)WikiDiscussions master Synced today

READMEChangelogDependenciesVersions (2)Used By (1)

LuckyBox
========

[](#luckybox)

LuckyBox is a library for PHP to pick up the one with a specified probability from some items.

Requirements
------------

[](#requirements)

- PHP 5.3.0 and up

Install
-------

[](#install)

In your application or dependent library root directory, create a composer.json file. In the require or alternatively in the require-dev section, add the following dependency:

```
"cloned/luckybox": "$VERSION"

```

with $VERSION being one of the versions available at [Packagist](https://packagist.org/packages/cloned/luckybox "Packagist").

Usage
-----

[](#usage)

### Example

[](#example)

Here is a simple example to pick up the item from 3 items which are Coin, Mushroom and Star. Probability of each item is below.

- Coin: 60%
- Mushroom: 35%
- Star: 5%

```
