+ 1

Did anyone know how increment alphabet works?(PHP)

If I use increment alphabet, for example a++ i get the result b. I don't understand how it works. How can PHP increment a string? Is it a temp array?

12th Sep 2017, 8:48 PM
Sebastian Kunert
Sebastian  Kunert - avatar
3 ответов
+ 2
every char have ascii code . for (a) its 97 so when u ++ its going to be 98 (b) and so on ... visit www.asciitable.com for more info
12th Sep 2017, 8:53 PM
Omid
Omid - avatar
+ 2
$x = 'A'; $x++; echo $x; $y = 'AB'; $y++; echo $y; $z = 'ABC'; $z++; echo $z; note : no DEcrement. or just in case you need specific increment , convert per Char to Ascii , substract / add , then put back to Char..
12th Sep 2017, 8:54 PM
Mikhael Anthony
Mikhael Anthony - avatar
+ 1
It is not ASCII because: z++ =aa. If its Ascii the result of z++ should be { .
12th Sep 2017, 8:57 PM
Sebastian Kunert
Sebastian  Kunert - avatar