Skip to content

Instantly share code, notes, and snippets.

@hasanfardous
Last active September 3, 2024 06:50
Show Gist options
  • Save hasanfardous/4041d88a25d0222f4f7a326d8e11f55a to your computer and use it in GitHub Desktop.
Save hasanfardous/4041d88a25d0222f4f7a326d8e11f55a to your computer and use it in GitHub Desktop.
Generate unique string each time by PHP
<?php
function generate_unique_string( $quantity ) {
$arr = [];
for( $i = 1; $i <= $quantity; $i++ ) {
$arr[] = sprintf('%08x', mt_rand(0, 0xFFFFFFFF));
}
return $arr;
}
// Generate 1000 unique strings of 8 Characters
generate_unique_string( 1000 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment