1. Go to this page and download the library: Download eram/abzar 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/ */
use Eram\Abzar\Validation\{NationalId, Iban, CardNumber, PhoneNumber};
// 1. ValidationResult for plain pass/fail checks with full error detail.
$r = CardNumber::validate('6037 9912 3456 7893');
$r->isValid(); // true
$r->detail()->bank; // 'بانک ملی ایران' (CardNumberDetails)
$r->errorCodes(); // [] (empty on success)
// 2. Null-returning variant.
$phone = PhoneNumber::tryFrom('+989121234567');
$phone?->e164(); // '+989121234567'
$phone?->operatorEnum(); // Operator::MCI
$phone?->isMobile(); // true
// 3. Value object on success — throws ValidationException on failure.
$ni = NationalId::from('0013542419');
$ni->value(); // '0013542419'
$ni->city(); // 'تهران مرکزی'
$ni->province(); // 'تهران'
$ni->cityCode(); // '001'
Iban::from('IR820540102680020817909002')->bankEnum(); // Bank::PARSIAN
PhoneNumber::normalize('+989121234567'); // '09121234567'
use Eram\Abzar\Format\NumberFormatter;
use Eram\Abzar\Format\NumberToWords;
use Eram\Abzar\Format\OrdinalNumber;
use Eram\Abzar\Format\TimeAgo;
NumberFormatter::withSeparators(1234567); // '1,234,567'
NumberFormatter::withSeparators('۱۲۳۴۵۶۷'); // '1,234,567'
NumberToWords::convert(1984); // 'یک هزار و نهصد و هشتاد و چهار'
NumberToWords::convert(3.25); // 'سه ممیز بیست و پنج'
OrdinalNumber::toWord(43); // 'چهل و سوم'
OrdinalNumber::toShort(43); // '۴۳ام'
TimeAgo::format(time() - 300); // '۵ دقیقه پیش'
use Eram\Abzar\Money\Amount;
use Eram\Abzar\Money\Currency;
$price = Amount::fromToman(50_000);
$price->inRials(); // 500000 (no ×10 confusion)
Currency::format($price->inToman()); // '۵۰،۰۰۰ تومان'
$price->add(Amount::fromToman(5_000))->inToman(); // 55000
use Eram\Abzar\Text\Script;
use Eram\Abzar\Text\Slug;
use Eram\Abzar\Text\CharNormalizer;
Script::isPersian('سلام دنیا'); // true
Script::hasArabic('متن فارسی با كلمة عربي'); // true
Slug::generate('سلام دنیا'); // 'سلام-دنیا'
Slug::generate('محصول ۱۲۳'); // 'محصول-123'
$n = new CharNormalizer();
$n->normalize('كتابي ٠١٢'); // 'کتابی ۰۱۲'
$n->normalizeContent('<p>كتابي</p>'); // '<p>کتابی</p>' (HTML-aware)
$n->normalizeForSearch('۱۲۳ كتاب'); // '123 کتاب' (digits → English)
use Eram\Abzar\Validation\{NationalId, CardNumber, LegalId, PhoneNumber, Iban, PostalCode, PlateNumber, PlateType};
// Valid-by-construction generators (tests / seed data only — may or may not be real)
$id = NationalId::fake(); // e.g. '0013542419'
$card = CardNumber::fake('603799'); // Luhn-valid card with pinned BIN
$legal = LegalId::fake();
$phone = PhoneNumber::fake(); // e.g. '09121234567' (or pin operator: fake('912'))
$iban = Iban::fake(); // e.g. 'IR82054…' (or pin bank code: fake('054'))
$postal = PostalCode::fake();
$plate = PlateNumber::fake(PlateType::TAXI); // pin category, or fake() for any
// Pull every valid ID out of free text (chat logs, OCR, scraped pages)
$ids = NationalId::extractAll('Customer 0013542419 and 1234567891 enrolled.');
$cards = CardNumber::extractAll('Paid via 6037 9912 3456 7893');
use Eram\Abzar\Text\{PersianCollator, HalfSpaceFixer};
$c = new PersianCollator(); // '); // 'میروم' (ZWNJ between prefix and verb)
HalfSpaceFixer::fix('خانه ها'); // 'خانهها'
HalfSpaceFixer::fix('بزرگ ترین'); // 'بزرگترین'
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.