PHP string Increment

Source: Internet
Author: User

Looking at PHP5 authority programming, see a description of a string increment:

Strings (non-numeric) are incremented in the same way as Perl. If the last letter is a literal or a number, it will be incremented by 1. If the last letter is ' z ', ' z ' or ' 9 ', it will be added to ' a ', ' a ' or ' 0 ', and the previous text or number will be incremented in the same way. If there is no previous text or number, it will be preceded by ' a ', ' a ' or ' 0 ', respectively. Don't feel like learning this a little headache, you just have to try and run it, you will soon master it.

Note: Non-numeric strings cannot be decremented.

At first glance, it seems to be hard to understand. But it's easy to understand a few examples:

$a = ' a '; $A = ' a '; $z = ' Z '; $Z = ' Z '; $az = ' AZ '; $AZ = ' AZ '; $aZ = ' AZ ';echo + + $a;//becho + + $A; Becho + + $z; Aaecho + + $Z; Aaecho + + $az; Baecho + + $AZ; Baecho + + $aZ; BA      

As you can see from the results, the addition and subtraction of strings is very similar to the addition and subtraction of numbers.

PHP string Increment

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.