On Fri, Apr 23, 2004 at 09:41:39PM +1000, electroteque wrote:
> use the chr($i) system

or range()...

  print implode(' | ', range('A', 'Z'));

- rob

> 
> > -----Original Message-----
> > From: Ford, Mike [LSS] [mailto:[EMAIL PROTECTED]
> > Sent: Friday, April 23, 2004 9:31 PM
> > To: 'Paul'; [EMAIL PROTECTED]
> > Subject: RE: [PHP] A to Z incremental
> >
> >
> > On 22 April 2004 15:22, Paul wrote:
> >
> > > Hi!
> > > Got this script:
> > >
> > > <?php
> > > for($i='A';$i<='Z';$i++){  echo $i.' | ';  }
> > > >
> > >
> > > The output is:
> > > A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P
> > > > Q | R | S | T | U | V | W | X | Y | Z |
> > >  AA | AB | AC |
> > >  ...
> > >   YX | YY | YZ |
> > >
> > > where is should display only letters from A to Z.
> > > Why is that?
> >
> > Because 'Z'++ (if you see what I mean!) is 'AA'.
> >
> > (So, at the end of the loop iteration which echoes 'Z', $i becomes 'AA',
> > which is <'Z', and as a result the loop continues on through all
> > the values
> > you saw.  The loop terminates after 'YZ' is echoed, since at the
> > end of that
> > iteration $i increments to 'ZA', which is not <'Z', and Bob's your uncle!)
> >
> > One way of solving this is:
> >
> >    for ($i='A'; $i!='AA'; $i++)
> >
> > Cheers!
> >
> > Mike
> >
> > ---------------------------------------------------------------------
> > Mike Ford,  Electronic Information Services Adviser,
> > Learning Support Services, Learning & Information Services,
> > JG125, James Graham Building, Leeds Metropolitan University,
> > Beckett Park, LEEDS,  LS6 3QS,  United Kingdom
> > Email: [EMAIL PROTECTED]
> > Tel: +44 113 283 2600 extn 4730      Fax:  +44 113 283 3211
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 

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

Reply via email to