I have a .ini file with contents of...
[template] color1 = 000000 color2 = ff6100 color3 = ff6100 color4 = 000000
And a file with contents belo
Use parse_ini:
parse_ini
$colors = parse_ini($path_to_ini, true); if(array_key_exists($myTheme, $colors)) { $myColor = $colors[$myTheme]['color' . $spot]; }
You don't need to compare $spot for each color - you can build the array key to get the value.