Tafqit-PHP is a PHP-based service designed to convert numerical values into readable text. Supporting both Arabic and English, this lightweight and modular solution can be easily extended to accommodate additional languages.
- Converts numbers into text in Arabic and English.
- Handles large numbers with precision.
- Supports customization for currency and subunit formatting.
- Lightweight and easy to integrate into any PHP project.
- PHP 7.0 or higher.
- Multibyte string extension (enabled by default in PHP).
-
Clone or download the repository.
-
Include the
src/Tafqit.php
file in your project:require_once 'path-to-src/Tafqit.php';
Here's an example of how to use Tafqit-PHP
to convert numbers to text:
<?php
require_once 'src/Tafqit.php';
$tafqit = new Tafqit();
echo $tafqit->numberToText("٢٣٤٥", 'ar'); // Outputs: ألفان وثلاثمائة وخمسة وأربعون
<?php
require_once 'src/Tafqit.php';
$tafqit = new Tafqit();
echo $tafqit->numberToText("2345", 'en'); // Outputs: Two thousand three hundred forty-five
You can customize it to include currency and subunit formatting for specific languages.
tafqit-php/
├── src/
│ └── Tafqit.php
├── examples/
│ └── example.php
├── tests/
│ └── TafqitTest.php
├── LICENSE
├── .gitignore
└── README.md
Run the tests using PHPUnit:
phpunit tests/TafqitTest.php
We welcome contributions! Follow these steps to contribute:
-
Fork the repository.
-
Create a new branch:
git checkout -b feature-branch
-
Make your changes and commit them:
git commit -m "Add new feature"
-
Push to your branch:
git push origin feature-branch
-
Open a Pull Request.
If you found this project helpful, please consider giving it a ⭐ on GitHub. Your support means the world to us!