Re: question

From: Date: Sun, 30 Mar 2003 12:58:40 +0000
Subject: Re: question
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-141637@lists.php.net to get a copy of this message
excuse me for being dumb, but can you explain this line for me? if (! (++$i % 2)) i've done scripts like this before, but never used anything like this? but then i never was a great coder :) thanks ----- Original Message ----- From: "Don Read" <dread@texas.net> To: "Marius" <mariusrk@delfi.lt> Cc: <php-general@lists.php.net> Sent: Sunday, March 30, 2003 1:54 PM Subject: RE: [PHP] question > > On 30-Mar-2003 Marius wrote: > > <?php > > $i = 0; > > $list = array('Banana', 'Strawberry', 'Apple', > > 'Cherry'); > > echo $list[$i]; > > $i = $i+1; > > ?> > > > > how to do that 2 of key echoes in first table colum and other 2 in > > second colum? > > > > Method 1: > > $i=0; > echo '<tr><td> > foreach($list as $v) { > > echo $v, '<br>'; > if (! (++$i % 2)) > echo '</td>'; > if ($i < count($list)) > echo '<td>'; > } > } > echo '</tr>'; > > > Method 2: > > echo '<tr>'; > unset($blk); > foreach($list as $v) { > if (count($blk) >= 2) { > echo '<td>', implode('<br>', $blk), > '</td>'; > unset($blk); > } > $blk[] = $v; > } >  > if (count($blk) ) > echo '<td>', implode('<br>', $blk), > '</td>'; > echo '</tr>'; > > > Regards, > -- > Don Read dread@texas.net > -- It's always darkest before the dawn. So if you are going to > steal the neighbor's newspaper, that's the time to do it. > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > >

« previous php.general (#141637) next »