I have two arrays. One with color names and the other with the RGB values.
I am converting a color name to it\'s RGB value using str_replace()
(then doi
That's because str_replace()
finds yellow
first (Because it's before Pale Yellow
in the array) and after this it can't find Pale
anymore. So use strtr() instead, like this:
$RGBvalue = strtr($colour, array_combine($RGBint, $ColourName));
To fix the issue change the order of Yellow / Pale Yellow in the $RGBint array.
Correct:
$RGBint = array('Red' ,'Burgundy','Rust' ,'Electric Orange','Pumpkin' ,'Melon' ,'Baby Pink' ,'Candy Floss Pink','Electric Pink', 'Pale Yellow','Yellow' ,'Golden' ,'Lime' ,'Kiwi' ,'Mint' ,'Dragonfly Green','Kelly Green','Fern' ,'Forest Green','Olive' ,'Teal' ,'Baby Blue' ,'Dragonfly Blue','Cornflower' ,'Medium Blue','Royal Blue','Electric Blue','Navy' ,'Lavender' ,'Lilac' ,'Purple' ,'Plum' ,'Dark Brown','Chocolate Brown','Light Brown','Copper' ,'Beige' ,'Linen' ,'Taupe' ,'Shimmer' ,'Silver' ,'Medium Grey','Charcoal' ,'Black', 'White' , 'Off White' , 'Neon Light Orange','Neon Orange','Neon Light Pink','Neon Dark Pink','Neon Yellow','Neon Green');