首頁 > php教程 > php手册 > 生成短地址

生成短地址

WBOY
發布: 2016-06-06 19:33:56
原創
1068 人瀏覽過

shorturl 无 ?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

short url
<?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<4;$i++){
	$temp=substr($hash, $i*8,8);
	$temp=base_convert($temp, 16, 10) & base_convert("3fffffff", 16, 10);

	$str="";
	for($j=0;$j<6;$j++){
		$subtemp=$temp & intval(base_convert("3d", 16, 10));
		$str.=$chars[$subtemp];
		$temp=$temp>>5;
	}
	unset($temp);
	$rs[]=$str;
}

print_r($rs);

?> 
登入後複製
相關標籤:
來源:php.cn
本網站聲明
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn
最新問題
熱門推薦
熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板