PHP code example of dannyps / ccidadao

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

    

dannyps / ccidadao example snippets



annyps\CCidadao\CCidadao;

$ver = [
    'min' => 1,
    'max' => 2,
];

$beg = 15000000;
$end = 15000100;

$arr = [];

for ($i = $beg; $i < $end; $i++) {
    for ($j = $ver['min']; $j <= $ver['max']; $j++) {
        array_push($arr, (new CCidadao($i . "_", $j))->__toString());
    }
}

// $arr now contains versions 1 and 2 of all CCs from 15000000 to 15000100. These are valid values.


annyps\CCidadao\CCidadao;

$cc = new CCidadao("15632563ZZ7");
$cc->next(); // advance current cc
echo ($cc);

// -- another method --

echo new CCidadao("15632563", 2);


annyps\CCidadao\CCidadao;

$valid = true;
try {
    new CCidadao("153666960ZZ1");
} catch(Exception $e){
    $valid = false;
}

var_dump($valid); // either true or false