PHP code example of laravel-myanmar-tools / nrc

1. Go to this page and download the library: Download laravel-myanmar-tools/nrc 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/ */

    

laravel-myanmar-tools / nrc example snippets


use LaravelMyanmarTools\Nrc\Nrc;

$nrc = new Nrc;

$nrc->isNrc('12/OUKAMA(N)123456'); // return true

$nrc->isNrc('12/OuKaMa(Naing)123456'); // return true

$nrc->isNrc('၁၂/ဥကမ(နိုင်)၁၂၃၄၅၆'); // return true

use LaravelMyanmarTools\Nrc\Nrc;

$nrc = new Nrc;

$nrc->normalizeNrc('12/OUKAMA(N)123456'); // return "12/OUKAMA(N)123456"
$nrc->normalizeNrc('12/OUKAMA(N)123456', 'mm'); // return "၁၂/ဥကမ(နိုင်)၁၂၃၄၅၆"

$nrc->normalizeNrc('12/OuKaMa(Naing)123456'); // return "12/OUKAMA(N)123456"
$nrc->normalizeNrc('12/OuKaMa(Naing)123456', 'mm'); // return "၁၂/ဥကမ(နိုင်)၁၂၃၄၅၆"

$nrc->normalizeNrc('၁၂/ဥကမ(နိုင်)၁၂၃၄၅၆'); // return "12/OUKAMA(N)123456"
$nrc->normalizeNrc('၁၂/ဥကမ(နိုင်)၁၂၃၄၅၆', 'mm'); // return "၁၂/ဥကမ(နိုင်)၁၂၃၄၅၆"

use LaravelMyanmarTools\Nrc\Nrc;
use Illuminate\Support\Str;

$nrc = new Nrc;

$nrc::macro('isYangon', function(string $nrc) {
   return Str::before($nrc, '/') == '12';
});

$nrc->isYangon('12/OuKaMa(Naing)123456'); // return true