Skip to content

Instantly share code, notes, and snippets.

@fcaldarelli
Created July 20, 2016 20:24
Show Gist options
  • Save fcaldarelli/e3bdc1b583f0e96a128eb93d9bc78039 to your computer and use it in GitHub Desktop.
Save fcaldarelli/e3bdc1b583f0e96a128eb93d9bc78039 to your computer and use it in GitHub Desktop.
Generate unique code string in PHP
<?php
// In this case, 4bytes, 8 charactes.
$bytes = 4;
$cstrong = true;
$uid = bin2hex(openssl_random_pseudo_bytes($bytes, $cstrong));
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment