Re: Couple of beginner questions

From: Date: Mon, 12 Jan 2009 21:47:25 +0000
Subject: Re: Couple of beginner questions
References: 1 2 3 4 5 6 7 8 9 10 11 12 13 14  Groups: php.general 
Request: Send a blank email to php-general+get-286168@lists.php.net to get a copy of this message
Nathan Rixham wrote:
Robert Cummings wrote:
On Mon, 2009-01-12 at 21:36 +0000, Nathan Rixham wrote:
Robert Cummings wrote:
On Mon, 2009-01-12 at 16:02 -0500, tedd wrote:
     
True, css does not allow numeric classes (like sessions). But, I never need them anyway.
As I provided before: http://webbytedd.com/b/color-rows/ this is my solution for alternating row style.
        
<tr class="row<?php echo($i++ & 1 );?>"> <td >abc</td> <td >abc</td> <td >abc</td> </tr> That's just wasteful... Here's better: <tr class="row<?php echo( $i ^= 1 );?>">
    <td >abc</td>
    <td >abc</td>
    <td >abc</td>
</tr> Cheers, Rob.
      
wtf? that's some freaky bug right there rob.. <?php for($i=0;$i<10;$i++) { ?> <tr class="row<?php echo( $i ^= 1 ); ?>">
     <td >abc</td>
     <td >abc</td>
     <td >abc</td>
</tr> <?php } ?> output: <tr class="row1">
     <td >abc</td>
     <td >abc</td>
     <td >abc</td>
</tr> <tr class="row3">
     <td >abc</td>
     <td >abc</td>
     <td >abc</td>
</tr> <tr class="row5">
     <td >abc</td>
     <td >abc</td>
     <td >abc</td>
</tr> <tr class="row7">
     <td >abc</td>
     <td >abc</td>
     <td >abc</td>
</tr> <tr class="row9">
     <td >abc</td>
     <td >abc</td>
     <td >abc</td>
</tr> php 5.2.5 - weird
    
Nooooooo... you introduced the bug, my code presumed a foreach loop and $i intialized to 0. You're code doesn't work with tedd's version either since you're incrementing $i in the loop and in the HTML output... thus it will always be even. Cheers, Rob.
but the rest should echo regardless..? doh scratch that

« previous php.general (#286168) next »