php生成短网址示例_PHP
程序员文章站
2022-06-13 23:54:16
...
php生成短网址
复制代码 代码如下:
$chars=array("a","b","c","d","e","f","g","h",
"i","j","k","l","m","n","o","p",
"q","r","s","t","u","v","w","x",
"y","z","0","1","2","3","4","5",
"6","7","8","9","A","B","C","D",
"E","F","G","H","I","J","K","L",
"M","N","O","P","Q","R","S","T",
"U","V","W","X","Y","Z");
$salt="www.joneto.com";
$hash=md5("http://www.sina.com".$salt);
$rs=array();
for($i=0;$i $temp=substr($hash, $i*8,8);
$temp=base_convert($temp, 16, 10) & base_convert("3fffffff", 16, 10);
复制代码 代码如下:
$chars=array("a","b","c","d","e","f","g","h",
"i","j","k","l","m","n","o","p",
"q","r","s","t","u","v","w","x",
"y","z","0","1","2","3","4","5",
"6","7","8","9","A","B","C","D",
"E","F","G","H","I","J","K","L",
"M","N","O","P","Q","R","S","T",
"U","V","W","X","Y","Z");
$salt="www.joneto.com";
$hash=md5("http://www.sina.com".$salt);
$rs=array();
for($i=0;$i $temp=substr($hash, $i*8,8);
$temp=base_convert($temp, 16, 10) & base_convert("3fffffff", 16, 10);
$str="";
for($j=0;$j $subtemp=$temp & intval(base_convert("3d", 16, 10));
$str.=$chars[$subtemp];
$temp=$temp>>5;
}
unset($temp);
$rs[]=$str;
}
print_r($rs);
?>
上一篇: php返回字符串中所有单词的方法,php返回字符串单词
下一篇: AJAX架构之Dojo篇_dojo