PHP code example of joshbruce / php-dice-bag

1. Go to this page and download the library: Download joshbruce/php-dice-bag library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

joshbruce / php-dice-bag example snippets


DiceBag::roll4d6()->highest(3)->sum();
// step 1: [3, 5, 2, 1]
// step 2: [5, 3, 2]
// step 3: 10

DiceBag::roll(4, 6)->highest(3)->sum();
// step 1: [3, 5, 2, 1]
// step 2: [5, 3, 2]
// step 3: 10

DiceBag::roll();
// rolls 1d6

DiceBag::roll(1, 6);
// rolls 1d6

Dn::withSides();
// roll 1 die with the given number of sides

composer