Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I get the next letter alphabetically without incrementing? (php)

for ($i=A;$i<L;$i++){                   
    echo $i;
    echo '->';
    echo ++$i;
    echo ', ';
}

gives me:

A->B, C->D, E->F, G->H, I->J, K->L

what I want is:

A->B, B->C, C->D, D->E, E->F, F->G

What's the simplest way to do this?

like image 354
pg. Avatar asked Dec 13 '22 03:12

pg.


1 Answers

Simple:

for ($i=A;$i<L;){  // remove loop increment                 
    echo $i;
    echo '->';
    echo ++$i;
    echo ', ';
}
like image 60
calebds Avatar answered Jan 05 '23 00:01

calebds