PHP code example of tifon / rut-php

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

    

tifon / rut-php example snippets



use Tifon\Rut\RutUtil;

RutUtil::validateRut('11.111.111-1');
// Or
RutUtil::validateRut(11111111, 1);


use Tifon\Rut\RutUtil;

$randomRutWithFormatter = RutUtil::generateRut();
// Generate rut between 1000000 and 2000000 and separate the check digit.
list($rut, $dv) = RutUtil::generateRut(FALSE, 1000000, 2000000);


use Tifon\Rut\RutUtil;

$rut = RutUtil::formatterRut(111111111);
// 11.111.111-1

// Or
$rut = RutUtil::formatterRut(11111111, 1, FALSE);
// 11111111-1


use Tifon\Rut\RutUtil;

list($rut, $dv) = RutUtil::separateRut('11.111.111-1');


use Tifon\Rut\Rut;

$rut = new Rut('11.111.111-1');
// Or
$rut = new Rut(11111111, 1);

echo $rut->getRut();
// 11111111
echo $rut->getDv();
// 1
echo $rut->getFormatter();
// 11.111.111-1
echo $rut->getRaw();
// 111111111
echo $rut->isValid();
// 1