note 44652 added to ref.strings

From: Date: Thu, 12 Aug 2004 05:52:56 +0000
Subject: note 44652 added to ref.strings
Groups: php.notes 
Request: Send a blank email to php-notes+get-74522@lists.php.net to get a copy of this message
Here's a simpler "simplest" way to toggle through a set of 1..n colors for web backgrounds: $colors = array('#000000', '#808080', '#A0A0A0', '#FFFFFF'); Call this whenever you want the next color: $color = next($colors) or $color = reset($colors); The code doesn't need to know anything about the number of elements being cycled through. That way you won't have to tracking down all the code when changing the number of colors or the color values. There's probably an easier syntax for this, perhaps a tertiary based on next($colors) ? ---- Manual Page -- http://www.php.net/manual/en/ref.strings.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+44652 Delete -- http://master.php.net/manage/user-notes.php?action=delete+44652&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+44652&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#74522) next »