php getnext,最有效的方法是使用PHP在字母表中獲得下一個字母。

8

Well, it depends what exactly you want to do with the "edge cases". What result do you expect when the character is z or Z? Do you want the next letter of the same case, or just the next letter, period?

這取決於你要怎么處理“邊緣情況”。當字符是z或z時,您期望得到什么結果?你想要同樣情況下的下一個字母,還是下一個字母,句號?

Without knowing the answer to that, for the very basic case, you can just do this:

在不知道答案的情況下,對於最基本的情況,你可以這樣做:

$next_character = chr(ord($current_character) + 1);

But when you're at Z this will give you [, and z will give you {, according to ASCII values.

但是當你在Z時,它會給你[,Z會根據ASCII值給你{。

Edited as per comment:

編輯/評論:

If you need the next character of the same case, you can probably just add simple checks after the line above:

如果您需要相同情況下的下一個字符,您可以在上面的行后添加簡單的檢查:

if ($next_character == '[')

$next_character = 'A';

else if ($next_character == '{')

$next_character = 'a';

These are very simple operations, I really wouldn't worry about efficiency in a case like this.

這些都是非常簡單的操作,在這種情況下我真的不會擔心效率。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值