mirror of
https://github.com/elyby/accounts.git
synced 2024-12-24 14:19:49 +05:30
19 lines
376 B
PHP
19 lines
376 B
PHP
|
<?php
|
||
|
namespace common\components;
|
||
|
|
||
|
|
||
|
class UserFriendlyRandomKey {
|
||
|
|
||
|
public static function make ($length = 18) {
|
||
|
$chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890';
|
||
|
$numChars = strlen($chars);
|
||
|
$key = '';
|
||
|
for ($i = 0; $i < $length; $i++) {
|
||
|
$key .= substr($chars, rand(1, $numChars) - 1, 1);
|
||
|
}
|
||
|
|
||
|
return $key;
|
||
|
}
|
||
|
|
||
|
}
|