Re: Feature Proposal: Allow letter decrementing
On Thu, 2013-07-18 at 07:46 -0600, Chris London wrote:
> My friend shared some code with me today that wasn't working for him. He
> was incrementing letters like this:
>
> $letter = 'A';
> echo ++$letter; // Output: B
>
> He was then trying to decrement letters like this:
>
> $letter = 'B';
> echo --$letter; // Output: B
>
> He was really confused why his code wasn't working. Obviously the answer
> is, PHP doesn't support decrementing letters.
Oviously this documented in
http://de2.php.net/manual/en/language.operators.increment.php
;-)
> My question is, why specifically doesn't it?
>
> It seems logical that if we support increment we should support decrement.
++$string; will always succeed. But what should $s = 'a'; --$s; result
in?
johannes
Thread (22 messages)