On Thu, Jul 3, 2008 at 1:32 PM, John Campbell <[EMAIL PROTECTED]> wrote:

> On Thu, Jul 3, 2008 at 12:45 PM, Michael Southwell
> <[EMAIL PROTECTED]> wrote:
> > John Campbell wrote:
> >>
> >> $p = explode('|',$y);
> >> for($i=0,$c = count($p);$i<$c;) {
> >> echo $p[$i++],' ', $p[$i++], "<br>\n";
> >> }
> >
> > I believe this will miss the first element of $p; you need instead:
> >
> > for ( $i = -1, $c = count( $p ); $i < $c; ) {
>
> If you start from -1, then you would need to use ++$i rather than $i++
>
> Starting from -1 and using ++$i would be faster than what I wrote.


Starting at -1 to avoid using ++$i seems way more confusing than starting at
0 and using $i++.  As someone mentioned above, confusing code will offset
any computation savings you gain.

>
> _______________________________________________
> New York PHP Community Talk Mailing List
> http://lists.nyphp.org/mailman/listinfo/talk
>
> NYPHPCon 2006 Presentations Online
> http://www.nyphpcon.com
>
> Show Your Participation in New York PHP
> http://www.nyphp.org/show_participation.php
>



-- 
Brian O'Connor
_______________________________________________
New York PHP Community Talk Mailing List
http://lists.nyphp.org/mailman/listinfo/talk

NYPHPCon 2006 Presentations Online
http://www.nyphpcon.com

Show Your Participation in New York PHP
http://www.nyphp.org/show_participation.php

Reply via email to