note 70972 added to language.operators.arithmetic
| From: | sean at somethinglikemedia dot com | Date: | Tue, 07 Nov 2006 00:02:01 +0000 |
| Subject: | note 70972 added to language.operators.arithmetic | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-119446@lists.php.net to get a copy of this message | ||
An easier way of doing alternating row colors is just setting the first row color outside of your
loop, calling your loop, and then calling the class or hex code into a single spot, rather than
re-creating the entire div both times.
Something like this:
<?php
$class = "odd";
for ($i = 1; $i <= 10; $i++) {
echo "<div
class=\"".$class."\">".$i."</div>";
if ($class == "odd") { $class = "even"; } else { $class = "odd";
}
}
?>
----
Server IP: 216.194.113.175
Probable Submitter: 68.6.225.111
----
Manual Page -- http://www.php.net/manual/en/language.operators.arithmetic.php
Edit -- https://master.php.net/note/edit/70972
Del: integrated -- https://master.php.net/note/delete/70972/integrated
Del: useless -- https://master.php.net/note/delete/70972/useless
Del: bad code -- https://master.php.net/note/delete/70972/bad+code
Del: spam -- https://master.php.net/note/delete/70972/spam
Del: non-english -- https://master.php.net/note/delete/70972/non-english
Del: in docs -- https://master.php.net/note/delete/70972/in+docs
Del: other reasons-- https://master.php.net/note/delete/70972
Reject -- https://master.php.net/note/reject/70972
Search -- https://master.php.net/manage/user-notes.php