Skip to content

Instantly share code, notes, and snippets.

@weaverryan
Created July 9, 2015 13:10
Show Gist options
  • Select an option

  • Save weaverryan/0046c2a861d33795f367 to your computer and use it in GitHub Desktop.

Select an option

Save weaverryan/0046c2a861d33795f367 to your computer and use it in GitHub Desktop.
Random string
<?php
/**
* Generates a random alphanumeric string
*
* @return string
*/
private static function generateOrderId()
{
// most characters, except those that look like others (e.g. o and 0)
$characters = 'ABCDEFGHJKMNPQRSTUVWXYZ23456789';
$string = '';
for ($i = 0; $i < 10; $i++) {
$string .= $characters[rand(0, strlen($characters) - 1)];
}
return $string;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment