Php language

$serial = "AA"; $serial[0] += 1; 

It doesn't work because php is dynamic, it just assigns $ serial = 1, and I need $ serial = "BA", what are the options? thank!

    1 answer 1

    Maybe it's not PHP?)

     $serial = "AA"; $serial[0] = chr(ord($serial[0]) + 1); echo $serial; 
    • I agree, things are always in the one who writes the code ... I just look at the possibilities of php. Could not resist and before that found another way) $ letters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'; $ serial [0] = $ letters (ord ($ serial [0] - 64)); but I like your variant more, by the way, I looked from the rot13 () method; I wonder why they didn’t do that either ... - Limpopo