php 字符串变短

WBOY
Release: 2016-06-23 14:00:16
Original
1501 people have browsed it

需求

$str='topics/new?forum_id=PHP';

echo shortUrl($str)  //    输出:js4d8x5d

echo unShortUrl('js4d8x5d')  //还原字符串    输出:topics/new?forum_id=PHP


求  shortUrl 和  unShortUrl 函数


回复讨论(解决方案)

没给出编码规则,怎么写程序?

短链接?
hash函数 + hash冲突解决方案 

新浪的短url貌似是在服务器存储的url和id号的对应关系。没有研究过

短链接?
hash函数 + hash冲突解决方案 

新浪的短url貌似是在服务器存储的url和id号的对应关系。没有研究过   
恩 短连接, 对应存储太麻烦了~ 也太多     hash这种类型php系统函数  好多,但是都是单向的。 我理想的是crc32  函数8位结果,但是crc32 也不能反

没给出编码规则,怎么写程序?
就是问这个

仅以计算得出的话,紧缩的空间有限
假定原串不含有中文,则可以用 96 进制表示 0000000 - 1011111
但只能紧缩 1/8

所以短网址都是以查表法实现的,提供的只是表项索引

仅以计算得出的话,紧缩的空间有限
假定原串不含有中文,则可以用 96 进制表示 0000000 - 1011111
但只能紧缩 1/8

所以短网址都是以查表法实现的,提供的只是表项索引
哦~,想学这个网站的url    http://hangzhou.8684.cn/z_d7bc763d

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!