Character increment

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
GinsBabu
Forum Newbie
Posts: 8
Joined: Sat Oct 24, 2009 7:00 am

Character increment

Post by GinsBabu »

Hi,

I am facing a scenario like above,but in my case i want to show up like Col A,Col B etc....The container where i am displaying this is being dynamically generated using jquery.Any help?
User avatar
papa
Forum Regular
Posts: 958
Joined: Wed Aug 27, 2008 3:36 am
Location: Sweden/Sthlm

Re: Character increment

Post by papa »

Using PHP you can create an array to retrieve letters from:

Code: Select all

 
$letters = range('a', 'z');
 
...
 
foreach (range('a', 'z') as $letter) {
    echo $letter;
}
Mark Baker
Forum Regular
Posts: 710
Joined: Thu Oct 30, 2008 6:24 pm

Re: Character increment

Post by Mark Baker »

Character increment seems to be flavour of the month
See this thread
GinsBabu
Forum Newbie
Posts: 8
Joined: Sat Oct 24, 2009 7:00 am

Re: Character increment

Post by GinsBabu »

Hi ,

Great thanks for ur responses(mark and papa)..i found out a solution for that..

char = 'a';
print ++$char . PHP_EOL;

that would do the trickk.:D
pbs
Forum Contributor
Posts: 230
Joined: Fri Nov 07, 2008 5:31 am
Location: Nashik, India
Contact:

Re: Character increment

Post by pbs »

One more option to display characters

Code: Select all

 
For Uppercase A - Z
for($i=65;$i<=90;$i++)
{   echo chr($i); }
 
For Lowercase a - z
for($i=97;$i<=122;$i++)
{   echo chr($i); }
 
Post Reply