PHP: “Increment” alphabet characters

Today I discovered that it is possible to “increment” alphabet characters in PHP.

$letter = "a";
$letter++;
echo($letter);

This will result in b. The same applies to capitals.
Note that character variables can be incremented but not decremented!

Now you wonder what happens if you reach the last letter in the alphabet:

$letter = "z";
$letter++;
echo($letter);

This will result in aa. The same applies to capitals.

Did you know this was possible with PHP?

Geef een reactie