PHP code example of markus-g / price-parser

1. Go to this page and download the library: Download markus-g/price-parser 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/ */

    

markus-g / price-parser example snippets



use PriceParser\Price;

$priceWithCurrency = '12,499,50 €';
$price = new Price($priceWithCurrency);

//float value e.g. 15.20
$price->getAmount();

//currency symbol, e.g. $ or €
$price->getCurrencySymbol();

//currency iso code, e.g. EUR or USD
$price->getCurrencyIsoCode();

//currency name, e.g. Euro or US Dollar
$price->getCurrencyName();

//the raw value, e.g. 12,499,50 €
$price->getValue();

//price is valid if a currency can be found and amount is not empty or null
$price->isValid();