Hi
Decrementing "a" to a number isn't a good idea because on incrementing
again you will increment the number and not go back to "a".
In my opinion this should be a warning/error and the value should stay
as "a".
This warning/error should be triggered on incrementing/decrementing a
non alphanumeric string (inclusive an empty string), too.
Greetings
Marc
Am 12.12.2013 21:02, schrieb Andrea Faulds:
> Good evening,
>
> At present, it's possible to increment (++) an alphanumeric string, such
> that "a" when incremented becomes "b", "z" becomes
> "aa", and so on.
>
> However, it's irritated me that the same is not true for the decrement
> (--) operator. At present, "aa" when decremented stays as "aa", and
> "b"
> when decremented stays as "b". This lack of symettry is counterintuitive
> to me. I don't think it's what you would expect here.
>
> So I've written a patch which would change this. "aa" when decremented
> would be "z", and "b" when decremented would be "a". It also
> handles
> decrementing "a", which becomes "0". This creates an interesting new
> asymettry: {$a = "a"; $a--; $a++;} will result in $a being integer 1. I
> think it's better than the previous behaviour, though, which resulted in
> "b".
>
> The diff is here:
> https://github.com/TazeTSchnitzel/php-src/compare/php:PHP-5.6...AlphanumericDecrement
>
>
> My aim is to try and get this into PHP 5.6, if people are interested.
> Thoughts?
>