Suppose I have a table like this
----Id----Product----RandomKey--
| 1 | P1 | (some key) |
----------------------------------
| 2 | P2 | (some key) |
----------------------------------
| 3 | P3 | (some key) |
----------------------------------
Here the some key is unique random key
I want to generate randome string from base_convert. Mean check the previous id suppose 3 and then increment 1 with the value and convert it with using base_convert
$rowid=3; //Get the last id from database
$bnum = base_convert($rowid,36,10);
$rkey = base_convert($bnum+1,10,36);
echo $rkey;
Does it always generate randome unique key? I really don't understand formbase and tobase in base_convert syntax
base_convert(number,frombase,tobase);
Can any one explain me how frombase and tobase work and by this method can i generate unique key?
Update:
If i set
$rkey = base_convert($bnum+1,10,36);
It will generate flat number, i want number with character. So I changed 36 to 16 mean Hexadecimal like
$rkey = base_convert($bnum+1,10,16);
and it will produce random string with number and character. If anyone recommend something better please let me know. Thanks