Re: [PHP] Re: Generate Alphabet

2002-01-02 Thread Daniel Grace

Bogdan Stancescu [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 2. print $letter++ -- why doesn't this evaluate to b at the first loop
when
 it's already 'a'? Ok, this I may be able to explain because it's neither
print
 ++$letter nor print ($letter++), but I wouldn't have trusted this
syntax to
 work this way a million years!


$foo++ is 'postfix', ++$foo is 'prefix' This means that the addition of 1
occurs AFTER (hence post) the expression's value is returned, not before.

In other words, it's equivalent to this:
print $foo;
$foo = $foo + 1;

not this:
$foo = $foo + 1;
print $foo;

-- Daniel Grace




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Re: Generate Alphabet

2001-12-28 Thread Bogdan Stancescu

Philip Olson wrote:

  I seriously doubt your code works -- have you tested it? I think the code
  you submitted will most probably output 1 2 3 4...24 25 26 (spaces are
  actually \n's). I never tested it though, so I may be mistaken.

 Yes, it works.  Test it before posting such doubts :)

 Regards,
 Philip Olson

Ok, tested it and to my surprize it does work. But why?!

Questions:
1. $letter++ -- why doesn't this evaluate $letter as integer before
incrementing?
2. print $letter++ -- why doesn't this evaluate to b at the first loop when
it's already 'a'? Ok, this I may be able to explain because it's neither print
++$letter nor print ($letter++), but I wouldn't have trusted this syntax to
work this way a million years!

Nice, elegant code indeed! Apologies for doubting it! :-)

Bogdan




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP] Re: Generate Alphabet

2001-12-27 Thread Jerry Verhoef (UGBI)

Sorry for the late reply but maybe you should take a look at the function
range.

from the manual:

foreach(range('a', 'z') as $letter) {
echo $letter;
}

Jerry
-Original Message-
From: Daniel Harik [mailto:[EMAIL PROTECTED]]
Sent: Monday, December 24, 2001 7:01 PM
To: [EMAIL PROTECTED]
Subject: Re: [PHP] Re: Generate Alphabet


Hello Fred,

Tuesday, December 25, 2001, 7:55:16 PM, you wrote:

F for ($Character = 65; $Character  91; $Character++)
F {
F echo chr($Character);
F }

F Fred

F Daniel Harik [EMAIL PROTECTED] wrote in message
F [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 Hello Guys,

 Just a stupid question how can i make php show from a-z with a for
 loop, don't want to make 26 hard coded links

 Thank You very much

 --
 Best regards,
  Daniel  mailto:[EMAIL PROTECTED]





Thank you

-- 
Best regards,
 Danielmailto:[EMAIL PROTECTED]


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]


The information contained in this email is confidential and
may be legally privileged. It is intended solely for the 
addressee. Access to this email by anyone else is 
unauthorized. If you are not the intended recipient, any 
form of disclosure, production, distribution or any action 
taken or refrained from in reliance on it, is prohibited and 
may be unlawful. Please notify the sender immediately.

The content of the email is not legally binding unless 
confirmed by letter bearing two authorized signatures.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Re: Generate Alphabet

2001-12-27 Thread Philip Olson


 This will only work with PHP 4.1.0 or later.

Consider this example:

$letter = 'a';
$i = 0;
while ($i++  26) {
  print Letter: . $letter++ .\n;
}
 
regards,
Philip Olson


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Re: Generate Alphabet

2001-12-27 Thread Bogdan Stancescu

I seriously doubt your code works -- have you tested it? I think the code
you submitted will most probably output 1 2 3 4...24 25 26 (spaces are
actually \n's). I never tested it though, so I may be mistaken.

However, with just a few changes we get
$letter='a';
$i=0;
while ($letter'z') {
  $letter=Chr(ord($letter)+$i);
  $i++;
  print($letterbr\n);
}
which should work.

Bogdan

Philip Olson wrote:

 Consider this example:

 $letter = 'a';
 $i = 0;
 while ($i++  26) {
   print Letter: . $letter++ .\n;
 }




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Re: Generate Alphabet

2001-12-27 Thread Philip Olson

 I seriously doubt your code works -- have you tested it? I think the code
 you submitted will most probably output 1 2 3 4...24 25 26 (spaces are
 actually \n's). I never tested it though, so I may be mistaken.

Yes, it works.  Test it before posting such doubts :)

Regards,
Philip Olson

 However, with just a few changes we get
 $letter='a';
 $i=0;
 while ($letter'z') {
   $letter=Chr(ord($letter)+$i);
   $i++;
   print($letterbr\n);
 }
 which should work.
 
 Bogdan
 
 Philip Olson wrote:
 
  Consider this example:
 
  $letter = 'a';
  $i = 0;
  while ($i++  26) {
print Letter: . $letter++ .\n;
  }
 
 
 


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Re: Generate Alphabet

2001-12-25 Thread Daniel Harik

Hello Fred,

Tuesday, December 25, 2001, 7:55:16 PM, you wrote:

F for ($Character = 65; $Character  91; $Character++)
F {
F echo chr($Character);
F }

F Fred

F Daniel Harik [EMAIL PROTECTED] wrote in message
F [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 Hello Guys,

 Just a stupid question how can i make php show from a-z with a for
 loop, don't want to make 26 hard coded links

 Thank You very much

 --
 Best regards,
  Daniel  mailto:[EMAIL PROTECTED]





Thank you

-- 
Best regards,
 Danielmailto:[EMAIL PROTECTED]


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]