×

Welcome to TagMyCode

Please login or create account to add a snippet.
0
0
 
0
Language: PHP
Posted by: Milan Vugrinchev
Added: Jan 4, 2016 3:18 PM
Modified: Jan 4, 2016 3:20 PM
Views: 7
Tags: unique id
Not unique but very hard to duplicate.
  1. <?php
  2.     $randomString = str_shuffle('abcdefghijklmnopqstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789');
  3.     $randomStart = rand(0, strlen($randomString)-1);
  4.     $randomLength = strlen($randomString) - $randomStart;
  5.     $uniqueId = substr($randomString, $randomStart, $randomLength);
  6. ?>