如何缩短数字串? [英] How to make string of numbers shorter?

查看:73
本文介绍了如何缩短数字串?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的网站导航如下:

http://www.newsbackup.com/index.php?...00000040900000


,具体取决于变量n。 (这总是一个数字),在网站的任何地方都会带我

...这个数字总是在变化,因为我有数百个

千页的文字在我的网站上。


问题:

- 在我看来,这不仅看起来很奇怪,而且变量n (数字)

太长了。


我需要一种以较短的形式表达这个数字的方法。一些编码

和解码方式将这个数字表示为更短的东西。

例如:000000000040900000可能变成类似:AhD7

所以链接: http://www.newsbackup.com/index.php?。 ..00000040900000

看起来像: http://www.newsbackup.com/index.php?n=AhD7


你知道我的意思。


所以,我试着想一想,我玩的想法是使用gzencode

或gzcompress。试了一下,但是这些会生成短代码,而不是正常的ascii,空格等等的...... b $ b字符....我不能用它,那么我的

网站不会对搜索引擎友好。


请你有什么建议吗?

或者一些短编码解码脚本?你的剧本可以永远属于我的网站

.


Joe

解决方案

< blockquote> .oO(Krakatioison)

我需要一种以较短的形式表达这个数字的方法。一些编码和解码方式将这个数字表示为更短的东西。
例如:000000000040900000可能变成类似:AhD7
所以链接: http://www.newsbackup.com/index.php?...00000040900000
会如下所示: http://www.newsbackup.com/index.php ?n = AhD7




如果n是实数(所以前导零不重要),那么你

可以尝试base_convert:


print base_convert(''000000000040900000'',10,36); //输出:ocmn4

print base_convert(''ocmn4'',36,10); //输出:40900000

http://www.php.net / base_convert


HTH

Micha


base64? (当然没有前导零)


" Michael Fesser" <是ne ***** @ gmx.net>在消息中写道

news:gn ******************************** @ 4ax.com ...

.oO(Krakatioison)

我需要一种以较短的形式表达这个数字的方法。一些编码和解码方式将这个数字表示为更短的东西。
例如:000000000040900000可能变成类似:AhD7
所以链接: http://www.newsbackup.com/index.php?...00000040900000
会如下所示: http://www.newsbackup.com/index.php ?n = AhD7



如果n是实数(所以前导零不重要),那么你可以试试base_convert:

print base_convert(''000000000040900000'',10,36); //输出:ocmn4
print base_convert(''ocmn4'',36,10); //输出:40900000

http://www.php.net / base_convert

HTH
Micha



问题是我需要那些前导零。没有

他们就行不通。

Hm ......但是好主意。非常感谢。

还有什么更好的主意吗?哪个永远不会削减我的前导零?


Joe


" Joep" <圣*** @ DeStoep.nl>在消息中写道

news:41 *********************** @ news.xs4all.nl ...

base64? (当然没有前导零)

Michael Fesser <是ne ***** @ gmx.net>在消息中写道
新闻:gn ******************************** @ 4ax.com ... < blockquote class =post_quotes> .oO(Krakatioison)

我需要一种以较短的形式表达这个数字的方法。一些
编码和解码方式将这个数字表示为更短的东西。
例如:000000000040900000可能变成类似:AhD7
所以链接: http://www.newsbackup.com/index.php?...00000040900000 <看起来像是: http://www.newsbackup.com /index.php?n=AhD7



如果n是实数(所以前导零不重要),那么你可以试试base_convert:

print base_convert(''000000000040900000'',10,36); //输出:ocmn4
print base_convert(''ocmn4'',36,10); //输出:40900000

http://www.php.net / base_convert

HTH
Micha




My sites navigation is like this:

http://www.newsbackup.com/index.php?...00000040900000

, depending on the variable "n" (which is always a number), it will take me
anywhere on the site... this number is always changing as I have hundreds of
thousand of pages of text on my site.

Problem:
- in my opinion this just not only look weird, but the variable "n" (number)
is too long.

I need a way to somehow express this number in shorter form. Some encoding
and decoding way to express this number as something shorter.
For example: 000000000040900000 could become something like : AhD7
so the link: http://www.newsbackup.com/index.php?...00000040900000
would look like: http://www.newsbackup.com/index.php?n=AhD7

You know what I mean.

So, I tried to think about it, and I played with the idea to use of gzencode
or gzcompress. Tried it, but these will generate the short code full of
characters out of normal ascii, spaces and so.... I can''t use that, then my
site won''t be search engine friendly.

Please, do you have any suggestions?
Or some short encoding decoding script? Your script can be forever part of
my site.

Joe

解决方案

.oO(Krakatioison)

I need a way to somehow express this number in shorter form. Some encoding
and decoding way to express this number as something shorter.
For example: 000000000040900000 could become something like : AhD7
so the link: http://www.newsbackup.com/index.php?...00000040900000
would look like: http://www.newsbackup.com/index.php?n=AhD7



If n is a real number (so that leading zeros don''t matter), then you
could try base_convert:

print base_convert(''000000000040900000'', 10, 36); // ouput: ocmn4
print base_convert(''ocmn4'', 36, 10); // output: 40900000

http://www.php.net/base_convert

HTH
Micha


base64? (without the leading zeroes of course)

"Michael Fesser" <ne*****@gmx.net> wrote in message
news:gn********************************@4ax.com...

.oO(Krakatioison)

I need a way to somehow express this number in shorter form. Some encoding
and decoding way to express this number as something shorter.
For example: 000000000040900000 could become something like : AhD7
so the link: http://www.newsbackup.com/index.php?...00000040900000
would look like: http://www.newsbackup.com/index.php?n=AhD7



If n is a real number (so that leading zeros don''t matter), then you
could try base_convert:

print base_convert(''000000000040900000'', 10, 36); // ouput: ocmn4
print base_convert(''ocmn4'', 36, 10); // output: 40900000

http://www.php.net/base_convert

HTH
Micha



Problem is that I need those leading zeros. It will just not work without
them.
Hm... But great Idea. Thanks a lot.
Any better idea? Which would never cut my leading zeros?

Joe


"Joep" <St***@DeStoep.nl> wrote in message
news:41***********************@news.xs4all.nl...

base64? (without the leading zeroes of course)

"Michael Fesser" <ne*****@gmx.net> wrote in message
news:gn********************************@4ax.com...

.oO(Krakatioison)

I need a way to somehow express this number in shorter form. Some
encoding
and decoding way to express this number as something shorter.
For example: 000000000040900000 could become something like : AhD7
so the link: http://www.newsbackup.com/index.php?...00000040900000
would look like: http://www.newsbackup.com/index.php?n=AhD7



If n is a real number (so that leading zeros don''t matter), then you
could try base_convert:

print base_convert(''000000000040900000'', 10, 36); // ouput: ocmn4
print base_convert(''ocmn4'', 36, 10); // output: 40900000

http://www.php.net/base_convert

HTH
Micha




这篇关于如何缩短数字串?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆