Php 使用parse_ini_文件将ini转换为所需格式的数组-未获得所需输出

Php 使用parse_ini_文件将ini转换为所需格式的数组-未获得所需输出,php,arrays,arraylist,Php,Arrays,Arraylist,我将数据拉入一个包含演示者信息的查询中。它的格式如下: [Doe, John undefined] middle_name = E. department = Psychology institution = Special State University city = Anywhere state = Texas country = USA office_phone = 123-456-7891 cell_phone = 123-789-4578 email_address = John_D

我将数据拉入一个包含演示者信息的查询中。它的格式如下:

[Doe, John undefined]
middle_name = E.
department = Psychology
institution = Special State University
city = Anywhere
state = Texas
country = USA
office_phone = 123-456-7891
cell_phone = 123-789-4578
email_address = John_Doe@there.edu
website = www.johndoe.edu

[Doe, Jane undefined]
middle_name = 
department = Political Science
institution = Special University
city = anywhere
state = Indiana
country = USA
office_phone = 123-456-7891
cell_phone = 568-456-4589
email_address = janedoe@here.edu
website = 
我真的需要它像这样显示:

约翰·多伊,心理学,特殊州立大学

简·多伊,政治学,特殊大学 (每个演示者在单独的行上)

我试过这个:

$cleanpresenters=parse_ini_文件($data['presenters'))

并在错误日志中生成:

 parse_ini_file([Doe, John undefined]\nmiddle_name = E.\ndepartment = Psychology\ninstitution = Special State University\ncity = Anywhere\nstate = Texas\ncountry = USA\noffice_phone = 123-456-7891\ncell_phone = \nemail_address = John_Doe@there.edu\nwebsite = \n\n): failed to open stream: File name too long in -File path name.proposalpdf.php on line 21, referer: Filepath name
我几乎是一个PHP新手,不知道下一步要做什么来修复错误并使它看起来像我想要的。可能只有一个演示者,也可能有几个演示者,因此解决方案需要循环,直到它在所有演示者中运行为止。任何帮助都将不胜感激

更新: 更改为解析_ini_字符串并回显数组,我得到以下结果:

Array
(
    [middle_name] => 
    [department] => Political Science
    [institution] => Special University
    [city] => Anywhere
    [state] => Indiana
    [country] => USA
    [office_phone] => 123-456-7891
    [cell_phone] => 568-456-4589
    [email_address] => janedoe@here.edu
    [website] => 
) 

到目前为止,一切顺利。我现在如何把它变成我想要的格式

我是根据研究和别人写的一个例子得出这个结论的

 //convert presenter data from array to string  
    $cleanpresenters = parse_ini_string($data['presenters'],TRUE);
    foreach ($cleanpresenters as $name=>$val1) 
    {
            $name = trim($name);
            $presenters[] = $name;
            $convertedPresenters .= "$name, {$val1['department']}, {$val1['institution']}\n";
    };

以上的方法奏效了。每个演示者在一行上打印姓名、部门、机构。谢谢你的提示和正确的方向

这个变量$data['presenters']是否保存该ini文件的文件路径?啊,您应该使用parse_ini_string谢谢!嗨,当我使用parse_ini_字符串并回显数组时,我得到了:
array([middle_name]=>[department]=>政治学[institution]=>特殊大学[city]=>任何地方[state]=>印第安纳州[country]=>美国[office_phone]=>123-456-7891[手机]=>568-456-4589[电子邮件地址] => janedoe@here.edu[网站]=>)
到目前为止,一切顺利。我现在如何把它变成我想要的格式?我还将把这一点补充到主要问题中。