imahmood/persian-text

A lightweight library for persian language localization.

v2.0.0 2023-09-17 07:44 UTC

This package is auto-updated.

Last update: 2024-05-01 00:11:33 UTC


README

Latest Stable Version GitHub Tests Action Status Total Downloads License

PersianText is a lightweight library for persian language localization.

Requirements

  • PHP 8.1 or greater
  • intl PHP extension

Installation

You can install this package via Composer:

$ composer require imahmood/persian-text

Usage

$string = '0123456789 - ۰١٢٣٤٥٦٧٨٩ - ي ك ة';

echo PersianText::text($string);
output: ۰۱۲۳۴۵۶۷۸۹ - ۰۱۲۳۴۵۶۷۸۹ - ی ک ه

echo PersianText::onlyArabicChars($string);
output: 0123456789 - ۰۱۲۳۴۵۶۷۸۹ - ی ک ه

echo PersianText::onlyNumbers($string);
output: ۰۱۲۳۴۵۶۷۸۹ - ۰۱۲۳۴۵۶۷۸۹ - ي ك ة

echo PersianText::toEnglishNumber($string);
output: 0123456789 - 0123456789 - ي ك ة

echo PersianText::money('123456789');
output: 123٬456٬789

echo PersianText::asSpellout(123456);
output: صد و بیست و سه هزار و چهارصد و پنجاه و شش

License

The MIT License (MIT). Please see License File for more information.