Php 如何生成唯一的18位post ID,如Pinterest?

Php 如何生成唯一的18位post ID,如Pinterest?,php,unique,pinterest,Php,Unique,Pinterest,我想用随机唯一的帖子ID而不是自动递增的帖子ID创建帖子 我发现Pinterest中的每一篇新帖子都有一个独特的18位帖子ID,比如 http://www.pinterest.com/pin/521432463078873423/ 这个18位数字是什么?创建新帖子时,如何在php中生成此数字 谢谢 此链接中的第三个选项允许您在创建GUID时指定长度。顺便说一句,谷歌是“Php如何创建GUID”的结果充满 谢谢,com\u create\u guid()应该可以工作,顺便说一句,如果链接像下面

我想用随机唯一的帖子ID而不是自动递增的帖子ID创建帖子 我发现Pinterest中的每一篇新帖子都有一个独特的18位帖子ID,比如

http://www.pinterest.com/pin/521432463078873423/
这个18位数字是什么?创建新帖子时,如何在php中生成此数字


谢谢

此链接中的第三个选项允许您在创建GUID时指定长度。顺便说一句,谷歌是“Php如何创建GUID”的结果充满


谢谢,com\u create\u guid()应该可以工作,顺便说一句,如果链接像下面的链接,而不是
?post=52143xxxxxxx?
http://www.pinterest.com/pin/521432463078873423/
以下是Pinterest的实际操作方式:
<?php

//set the random id length 
$random_id_length = 18; 

//generate a random id encrypt it and store it in $rnd_id 
$rnd_id = crypt(uniqid(rand(),1)); 

//to remove any slashes that might have come 
$rnd_id = strip_tags(stripslashes($rnd_id)); 

//Removing any . or / and reversing the string 
$rnd_id = str_replace(".","",$rnd_id); 
$rnd_id = strrev(str_replace("/","",$rnd_id)); 

//finally I take the first 18 characters from the $rnd_id 
$rnd_id = substr($rnd_id,0,$random_id_length); 

echo "Random Id: $rnd_id" ;
echo "<br>";

?>