View Single Post
Old 03-16-2009, 10:09 PM   #3 (permalink)
Wildhoney
La Vida es Sueño
Advanced Programmer Top Contributor 
 
Wildhoney's Avatar
 
Join Date: Sep 2007
Location: Oldham
Posts: 2,280
Thanks: 90
Wildhoney is on a distinguished road
Default

How about the following? It looks a little more elegant than a huge switch statement. Village Idiot is also right; please do not remove your questions as it could well help other people in the future.

php Code:
$iDateStatus       = 2;
$aStatusColours     = array('FFFFFF', '000000', 'CCCCCC', '669900');
$szStatusColour     = null;

if ($iDateStatus != null) /* != "1"? */
{
    $szStatusColour =   isset($aStatusColours[$iDateStatus])  ?
                        $aStatusColours[$iDateStatus]       :
                        null;
}

printf("Colour is: %s", $szStatusColour);
__________________
The man who comes back through the Door in the Wall will never be quite the same as the man who went out.
Send a message via AIM to Wildhoney Send a message via MSN to Wildhoney Send a message via Yahoo to Wildhoney
Wildhoney is offline  
Reply With Quote