PHP code example of gabrielandy / coindesk

1. Go to this page and download the library: Download gabrielandy/coindesk 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/ */

    

gabrielandy / coindesk example snippets


use Coindesk;

/**
 * Convert any supported Coindesk's fiat currency to Bitcoin.
 *
 * @example Coindesk::toBtc(1, 'USD')
 *
 * @param  int  $amount             - The amount of the currency in integer/numeric
 * @param  string  $currency = USD  - The currency you wish to convert to Bitcoin
 * @return string
 */
Coindesk::toBtc($amount, $currency_code);

Coindesk::toBtc(1, 'USD'); // This will return 0.000027 stating that $1 = ₿0.000027
Coindesk::toBtc(1, 'EUR'); // This will return 0.000034 stating that €1 = ₿0.000034
Coindesk::toBtc(1, 'NGN'); // This will return 0.000000067 stating that ₦1 = ₿0.000000067