Re: why is 0 first?
- From: a.r.ferreira@xxxxxxxxx (Adriano Ferreira)
- Date: Tue, 27 Dec 2005 13:16:23 -0200
> I am curious what the reasoning behind the first element of
> something being zero is ($array[0]). I know I've read it before, but
> I can't remember. Thanks!
Using indices 0 .. n make it possible to work with them like offsets
from the beginning of the array. More important from a C point of
view, where it may even improve performance. Ah, and for loops are
shorter by one character ;)
for ( $i=0; $i<$n; $i++ ) { .. }
rather than
for ( $i=1; $i<=$n; $i++ ) { ... }
.
- Follow-Ups:
- Re: why is 0 first?
- From: usenet
- Re: why is 0 first?
- From: Dr.Ruud
- Re: why is 0 first?
- From: Daniel Lord
- Re: why is 0 first?
- References:
- why is 0 first?
- From: The Ghost
- why is 0 first?
- Prev by Date: why is 0 first?
- Next by Date: RE: file :: find problem
- Previous by thread: why is 0 first?
- Next by thread: Re: why is 0 first?
- Index(es):
Relevant Pages
|