October 23, 201016 yr Sorry if there is a simple answer to this, but my PHP is poor at best I'm looping through a string incrementing characters as I go, and I need to be able to decrement them back to their original state later on in the script. Is there anyway to decrement a char so 'b' would become 'a', etc? I'm surprised you can't $letter--, as you can $letter++.. Thanks in advance.
October 23, 201016 yr Sorry if there is a simple answer to this, but my PHP is poor at best I'm looping through a string incrementing characters as I go, and I need to be able to decrement them back to their original state later on in the script. Is there anyway to decrement a char so 'b' would become 'a', etc? I'm surprised you can't $letter--, as you can $letter++.. Thanks in advance. Try this --$letter
October 23, 201016 yr Author $letter = chr(ord($letter) - 1); Yes I had tried the $letter--; and didn't understand why it doesn't work. This method works for me though, thankyou!
Create an account or sign in to comment