php生成短网址的方法

来源:不言 发布时间:2018-12-05 15:49:41 阅读量:879

这篇文章主要介绍了php生成短网址示例,需要的朋友可以参考下

php生成短网址

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

<?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中文网!

相关推荐:

如何通过php获取随机数组列表

php将时间差转换为字符串的实现


标签: PHP
分享:
评论:
你还没有登录,请先