Random String The Easy Way

- https://github.com/vinkla/laravel-hashids
- http://stackoverflow.com/questions/4407161/find-duplicate-strings-in-database

function rndmHash()
{
  // get the current time in nanosecond 
  // to make sure the duplication margin is small
  // then hash it
  $string = system('date +%s%N');
  return Hashids::encode($string).'.jpg';
}

foreach ($x as $y) {
  // ...

  // get a new random on each iteration
  $name = rndmHash();
}
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s