打印阵列信息

时间:2013-12-18 17:56:51

标签: php

我有一个方法,它将3个数组作为参数,然后根据传递的3个数组的值创建一个数组。然后将此信息发送到发送它的电子邮件方法。它一直运作良好,直到现在。问题是我的键值配对。有些值不打印,我不知道为什么。为了便于说明,我省略了不相关的代码。看看......

public function SendToISS($user,$questions,$scores_translated) {    

    $userinfo = array("First Name:"=>$user['first'],
                      "Last Name:"=>$user['last'],
                    "Organization:"=>$user['org'],
                      "State:"=>$user['state'],
                      "Zip:"=>$user['zip'],
                    "Phone:"=>$user['phone'],
                    "Email:"=>$user['email'],
                    ""=>"",

                    "Assessment Answers:"=>"",

                    "Assessment One:"=>$questions[0],
                    "  ".$user['first']."'s Answer:"=>$scores_translated[0],

                    "Assessment Two:"=>$questions[1],
                    "  ".$user['first']."'s Answer:"=>$scores_translated[1],

                    "Assessment Three:"=>$questions[2],
                    "  ".$user['first']."'s Answer:"=>$scores_translated[2],

                    "Assessment Four:"=>$questions[3],
                    "  ".$user['first']."'s Answer:"=>$scores_translated[3],

                    "Assessment Five:"=>$questions[4],
                    "  ".$user['first']."'s Answer:"=>$scores_translated[4]
                    );

}

这是我的电子邮箱中的结果。 scores_translated数组仅打印第一个值,然后停止。

 First Name: Steven
 Last Name: Pepe
 Organization: Laerdal
 State: New York
 Zip: 12590
 Phone: 8452977770
 Email: steven.pepe@laerdal.com

 Assessment Answers: 
 Assessment One: Administer multiple assessments of student progress throughout the class.
  Steven's Answer: The program does not perform this strategy.
 Assessment Two: Establish a passing standard for psychomotor and critical thinking skills that is above the minimum competency level.
 Assessment Three: The program does not perform this strategy.
 Assessment Four: Assure instructional consistency when preparing students for the NREMT-B exam.
 Assessment Five: Provide immediate feedback for written, practical evaluations to students.

2 个答案:

答案 0 :(得分:1)

你的钥匙不是唯一的。这是您在数组中使用的密钥,只能设置一次"  ".$user['first']."'s Answer:"

您需要"  ".$user['first']."'s Answer One:"之类的内容作为回复的关键

答案 1 :(得分:1)

您似乎使用相同的键进行同样的操作。也就是说,您使用"  ".$user['first']."'s Answer:"作为五个不同事物的关键,并且只是覆盖而不是追加。我不确定为什么以前一直在工作。

尝试切换到"  ".$user['first']."'s Answer #1:"之类的内容,然后对其进行编号,看看是否能修复它。