Condensing multiple else if statements, referencing them from a table?
- by Haskella
Hi I'm about to type some 500 else if statements into my code (PHP) which have the exact same coding each:
if (color=White);
rgb = 255-255-255;
print rgb;
else if (color=Black);
rgb = 0-0-0;
print rgb;
else if (color=Red);
rgb = 255-0-0;
print rgb;
else if (color=Blue);
rgb = 0-0-255;
print rgb;
[the list keeps going]
I also (luckily) have a table that displays the color in the first column and rgb value in the next column for 500 of them... how do I use this to save time typing all those else if statements? Some how I have to reference the table file (made in excel, I'm guessing I'll have to save it as .csv?)