Skip to content

Instantly share code, notes, and snippets.

@vzabaznov
Created October 1, 2014 12:01
Show Gist options
  • Select an option

  • Save vzabaznov/4eb37365ce116fff04af to your computer and use it in GitHub Desktop.

Select an option

Save vzabaznov/4eb37365ce116fff04af to your computer and use it in GitHub Desktop.
generate unique number(not id)
public static function generateUniqueNumber($len = 9)
{
$numbers = '0123456789';
$result = mb_substr($numbers, rand(0, $len),1);
for ($i = 1; $i < $len; $i++) {
$result .= mb_substr($numbers, rand(0, $len),1);
}
return $result;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment