如何在PHP中增加数字之类的字母? [英] How to increment letters like numbers in PHP?

查看:80
本文介绍了如何在PHP中增加数字之类的字母?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想编写一个函数,该函数接受3个字符并将其递增,然后将新递增的字符作为字符串返回.

I would like to write a function that takes in 3 characters and increments it and returns the newly incremented characters as a string.

我知道如何将单个字母增加到下一个字母,但是我怎么知道何时增加第二个字母,然后停止然后再增加第一个字母以实现顺序增加?

I know how to increase a single letter to the next one but how would I know when to increase the second letters and then stop and then increase the first letter again to have a sequential increase?

因此,如果通过了AAA,则返回AAB.如果 通过AAZ返回ABA(困难部分).

So if AAA is passed, return AAB. If AAZ is passed return ABA (hard part).

我希望能提供有关逻辑方面的帮助以及可以使用哪些PHP函数的帮助.

I would appreciate help with the logic and what php functions will be useful to use.

更好的是,已经完成了一些操作,或者有一个可用的类来执行此操作吗?

Even better, has some done this already or there is a class available to do this??

感谢所有帮助

推荐答案

字符/字符串的增量在PHP中有效(尽管不能减量)

Character/string increment works in PHP (though decrement doesn't)

$x = 'AAZ';
$x++;
echo $x;

这篇关于如何在PHP中增加数字之类的字母?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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