PHP code example of thesmarter / tafqeet

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

    

thesmarter / tafqeet example snippets


use thesmarter\Tafqeet\Core\Tafqeet;

echo Tafqeet::arablic(3150.9);
// Output: فقط ثلاثة آلاف ومائة وخمسون ريالاً وتسعة هللات لاغير

use thesmarter\Tafqeet\Core\Tafqeet;

// Simple usage (default currency: Saudi Riyal)
echo Tafqeet::arablic(3150.9);
// Output: فقط ثلاثة آلاف ومائة وخمسون ريالاً وتسعة هللات لاغير

// With custom currency
echo Tafqeet::arablic(1500.50, 'usd');
echo Tafqeet::arablic(500.25, 'sdg');

use thesmarter\Tafqeet\Core\Tafqeet;

$tafqeet = new Tafqeet(123456.78);
echo $tafqeet->toWords('sar');

use thesmarter\Tafqeet\Core\Tafqeet;
use thesmarter\Tafqeet\Exception\TafqeetException;

try {
    echo Tafqeet::arablic('not a number');
} catch (TafqeetException $e) {
    echo 'Error: ' . $e->getMessage();
}

Tafqeet::arablic(0);           // صفر ريال لاغير
Tafqeet::arablic(1);           // فقط واحد ريال لاغير
Tafqeet::arablic(10);          // فقط عشرة ريال لاغير
Tafqeet::arablic(100);         // فقط مائة ريال لاغير
Tafqeet::arablic(1000);        // فقط ألف ريال لاغير
Tafqeet::arablic(1100);        // فقط ألف ومائة ريال لاغير
Tafqeet::arablic(10000);       // فقط عشرة آلاف ريال لاغير
Tafqeet::arablic(100000);      // فقط مائة ألف ريال لاغير
Tafqeet::arablic(123456);      // فقط مائة وثلاثة وعشرون ألفًا وأربعمائة وستة وخمسون ريالاً لاغير
Tafqeet::arablic(999999.99);   // تسعمائة وتسعة وتسعون ألفًا وتسعمائة وتسعة وتسعون ريالاً وتسعة وتسعون هللة لاغير
bash
composer dump-autoload

Tafqeet/
├── src/
│   ├── Core/
│   │   └── Tafqeet.php          # Main class
│   └── Exception/
│       └── TafqeetException.php  # Custom exception
├── tests/                        # Tests
├── test.php                      # Quick demo
├── composer.json
├── phpunit.xml
└── README.md