需要解析ini文件来提取值 [英] Need to parse ini file to extract values

查看:57
本文介绍了需要解析ini文件来提取值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个包含...内容的 .ini 文件

I have a .ini file with contents of...

[template]
color1 = 000000
color2 = ff6100
color3 = ff6100
color4 = 000000

下面的文件是从functions.php调用的,它传入了2个值:

And a file with contents below which is called from functions.php which passes in 2 values:

$myTheme,这是正在寻找颜色的主题/模板的名称和 $spot,这是正在寻找的特定颜色编号(颜色 1-4)

$myTheme, which is the name of the theme/template whose colors are being sought and $spot, which is the specific color number being sought (colors 1-4)

$myTheme = $_REQUEST['theme'];
$spot = $_REQUEST['spot'];
$myColor = get_option($myTheme);

    $path_to_ini = "styles/". $myTheme . "/template.ini";

if ($myColor == "") {
     if($spot == 1){$myColor = [insert color1 value here];}
     if($spot == 2){$myColor = [insert color2 value here];}
     if($spot == 3){$myColor = [insert color3 value here];}
     if($spot == 4){$myColor = [insert color4 value here];}
}

echo $myColor;

我正在寻求有关如何解析 ini 文件以使用 template.ini 文件中的适当颜色填充括号数据的帮助.

I'm looking for help with how to parse the ini file to fill in the bracketed data with the appropriate color from the template.ini file.

推荐答案

您可以使用 parse_ini_file()

这篇关于需要解析ini文件来提取值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆