>> > imgBkgrnd = array("1"=> "bkgrnd-default.gif", "2" =>
>> > "bkgrnd-positive.gif", "3" => "bkgrnd-negative.gif");
>>
>> You got it...
>>
>> imgBkgrnd = array("1"=> "bkgrnd-default.gif", "2" =>
>> "bkgrnd-positive.gif",
>> "3" => "bkgrnd-negative.gif");
>> imgNeeded = table['field'];
>> imgName = ???
>>
>
>
> http://us3.php.net/array
>
> $imgBkgrnd = array("1"=> "bkgrnd-default.gif", "2" =>
> "bkgrnd-positive.gif", "3" => "bkgrnd-negative.gif");
> $imgNeeded = table['field'];
> $imgName = $imgBkgrnd[$imgNeeded];
>
Yup, just like that.
You can even get away with just:
$imgBkgrnd = array("1"=>
"bkgrnd-default.gif","bkgrnd-positive.gif","bkgrnd-negative.gif");
as PHP will automatically assign bkgrnd-positive.gif with 2 and
bkgrnd-negative.gif with 3.
And can even do this:
$imgName = $imgBkgrnd[$table['field']];
Though I admit it looks clunky.
--
--Matthew Sims
--<http://killermookie.org>
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php