[PHP] Letter incrementing

2004-03-18 Thread Brent Clark
Hi all

Does anyone know how, or even if it is possible to increment a letter from the 
alphabet.

I know that if you use 
e.g

$o = 1;
$o++;

will result in $o ==  2,.

But I need to do a $variable = B;
and then do a $variable++ that will result in
$variable == C

Kind Regards
Brent Clark


Re: [PHP] Letter incrementing

2004-03-18 Thread Richard Davey
Hello Brent,

Thursday, March 18, 2004, 1:16:34 PM, you wrote:

BC Does anyone know how, or even if it is possible to increment a letter from the 
alphabet.

BC But I need to do a $variable = B;
BC and then do a $variable++ that will result in
BC $variable == C

Sure:

?php
 $letter = a;
 $letter++;
 echo $letter;
?

You'll get b :)

-- 
Best regards,
 Richard Davey
 http://www.phpcommunity.org/wiki/296.html

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Letter incrementing

2004-03-18 Thread Brent Baisley
You want to use the char() function. What you need to do is increment 
an ascii value and then convert that value to a letter. So ascii 65 is 
A.
$asciiVal = 65;
echo char($asciiVal);  A
$asciiVal++;
...

On Mar 18, 2004, at 8:16 AM, Brent Clark wrote:

Hi all

Does anyone know how, or even if it is possible to increment a letter 
from the alphabet.

I know that if you use
e.g
$o = 1;
$o++;
will result in $o ==  2,.

But I need to do a $variable = B;
and then do a $variable++ that will result in
$variable == C
--
Brent Baisley
Systems Architect
Landover Associates, Inc.
Search  Advisory Services for Advanced Technology Environments
p: 212.759.6400/800.759.0577
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Letter incrementing

2004-03-18 Thread Justin Patrin
echo char(ord('A') + 1);

Brent Baisley wrote:

You want to use the char() function. What you need to do is increment an 
ascii value and then convert that value to a letter. So ascii 65 is A.
$asciiVal = 65;
echo char($asciiVal);  A
$asciiVal++;
...

On Mar 18, 2004, at 8:16 AM, Brent Clark wrote:

Hi all

Does anyone know how, or even if it is possible to increment a letter 
from the alphabet.

I know that if you use
e.g
$o = 1;
$o++;
will result in $o ==  2,.

But I need to do a $variable = B;
and then do a $variable++ that will result in
$variable == C


--
paperCrane Justin Patrin
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Letter incrementing

2004-03-18 Thread David Otton
On Thu, 18 Mar 2004 15:16:34 +0200, you wrote:

But I need to do a $variable = B;
and then do a $variable++ that will result in
$variable == C

for ($i = 0; $i  26; $i++)
{
  echo (chr($i + ord('A')));
}


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php