I having an issue with associative arrays. I created my array called numFromCountries and I defined a bunch of colors. I want to walk through the array and check the number of each country. If the number is from 1-9 I want to assign it a red color, if it is 10-19 I want to assign it a green color, etc. Can I only stick strings into associative arrays? I'm having a problem sticking the defined colors in as a value. Here is the code:
$numFromCountries = array("Russia" => "100", "USA" => "50", "Canada" => "20", "Mexico" => "70", "Latvia" => "4");
$red = ImageColorAllocate($img_file, 255, 0, 0);
$green = imagecolorallocate($img_file, 79, 228, 68);
$blue = imagecolorallocate($img_file, 68, 75, 228);
$purple = ImageColorAllocate($img_file, 192, 26, 178);
$yellow = ImageColorAllocate($img_file, 222, 255, 0);
$orange = ImageColorAllocate($img_file, 255, 144, 0);
$pink = ImageColorAllocate($img_file, 255, 134, 217);
$brown = ImageColorAllocate($img_file, 150, 80, 18);
$gray = ImageColorAllocate($img_file, 150, 150, 150);
$cyan = ImageColorAllocate($img_file, 0, 255, 255);
//$black = ImageColorAllocate($img_file, 0, 0, 0);
foreach($numFromCountries as $key => $val)
{
if($val > 0 && $val < 10)
$colorOfCountries = array($key => $red);
print("key is: ".$colorOfCountries[$key]);
}