PHP code example of am-mokhtari / numeric-code

1. Go to this page and download the library: Download am-mokhtari/numeric-code 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/ */

    

am-mokhtari / numeric-code example snippets


$string_code = NumericCode::generate(5);

$string_code = NumericCode::generate(4);



okhtari\NumericCode\NumericCode;

$start = microtime(true);
for ($i = 0; $i < 1_000; $i++){
    try {
        NumericCode::generate(8); // Generate an 8-digit code
    } catch (Exception $e) {
        echo "Error: " . $e->getMessage() . " <br>";
    }
}
$end = microtime(true);
$executionTime = $end - $start;
echo "Execution Time: " . number_format($executionTime, 6) . " seconds <br>";

$string_code = NumericCode::generate(5);

$string_code = NumericCode::generate(4);



okhtari\NumericCode\NumericCode;

$start = microtime(true);
for ($i = 0; $i < 1_000; $i++){
    try {
        NumericCode::generate(8); // Generate an 8-digit code
    } catch (Exception $e) {
        echo "Error: " . $e->getMessage() . " <br>";
    }
}
$end = microtime(true);
$executionTime = $end - $start;
echo "Execution Time: " . number_format($executionTime, 6) . " seconds <br>";