2013-12-18 161 views
1

我有一個方法需要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: [email protected] 

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. 
+1

請指定_what_丟失。 –

+0

@SergiuParaschiv我希望每個問題都能看到「Steven's Answer:」一次。我不知道,爲什麼沒有打印。 – zebediah49

+0

缺少的是「評估一:」之後的其他鍵值對。他們也應該包含分數。你可以在電子郵件結果中看到這一點。 – stevenpepe

回答

1

你似乎是使用相同的密鑰對同一件事的反應。也就是說,你使用"  ".$user['first']."'s Answer:"作爲五個不同事物的關鍵,並且只是重寫而不是追加。我不確定爲什麼這會在第一時間工作。

嘗試切換到類似"  ".$user['first']."'s Answer #1:"的東西,並對它們進行編號,以查看是否修復它。

+0

有時候,鼻子下面總是有些東西。謝謝。就是這樣。 – stevenpepe

1

你的鑰匙不是唯一的。這是您使用的數組中的關鍵,它只能使用一次,"  ".$user['first']."'s Answer:"

你需要像"  ".$user['first']."'s Answer One:"的按鍵設置爲

+0

我們似乎發佈了相同的答案,相隔7秒。 – zebediah49

+0

哈哈,所以我注意到了。 – elitechief21