PHP code example of sonypradana / convertcode

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

    

sonypradana / convertcode example snippets




use Convert\Converter\ConvertCode;

$ccode = new ConvertCode();

$ccode->setNumber( 999999 );  // creat id by 99
echo $ccode->getCode();       // will out put -> 4c81

$ccode->setCode( '4c82' );  // creat id by code "4c82"
echo $ccode->getNumber();   // will out put -> 1000000

// plus (+) operator
$ccode->plusOperator(1);    // plus 1
echo $ccode->getNumber();   // will out put -> 1000001
echo $ccode->getCode();     // will out put -> ac83

// minus (-) operator
$ccode->minusOperator(2);    // minus 2
echo $ccode->getNumber();   // will out put -> 999999
echo $ccode->getCode();     // will out put -> ac81

use ConvertCode\Converter\ConvertCode;

$id_number = ConvertCode::ConvertFromCode( "0B" );
echo $id_number; // will out put 99

use ConvertCode\Converter\ConvertCode;

$id_code = ConvertCode::ConvertFromNumber( 99 );
echo $id_code; // will out put "0B"

use ConvertCode\Converter\ConvertCode;

$id_code = ConvertCode::RandomCode( 4 ); // how many digit code you want
echo $id_code; // random code 
bash
php CLI test 1 100
bash
php CLI 
php CLI to-code [number]
php CLI from-code [string_code]