2017-08-07 3 views
0

なんらかの理由で、電子メールの件名をエコーアウトするのに問題があります。まあ、実際には1つの対象がエコーアウトされますが、1つだけ残り残りはエコーされません。私は他の話題に似たソリューションを試してみましたが、誰も働いていません前もって感謝します。私のコードは以下の通りです。phpでheaderinfoから件名を取得する際に問題が発生しました

 function inbox() { 

     $this->msg_cnt = imap_num_msg($this->conn); 

     $in = array(); 
     for($i = 1; $i <= $this->msg_cnt; $i++) { 
      $in[] = array(
       'index'  => $i, 
       'header' => imap_headerinfo($this->conn, $i), 
       'body'  => imap_body($this->conn, $i), 
       'structure' => imap_fetchstructure($this->conn, $i) 
      ); 
      if(property_exists($this->inbox[$i]['header'], 'subject')){ 
       $header = $this->inbox[$i]['header']; 
       $subject = $header->subject; 
       echo $subject; 
     } 

     $this->inbox = $in; 

    } 
} 
+2

[MCVE]読んで、より多くの光を当てるしてください。 –

答えて

1

これは単なる推測ですが、私はあなたが理由で$ in配列を作成していると仮定しようとしています。あなたは$ inを使用することを無視します。ここで

は、私はあなたがするもので信じるものである:

function inbox() { 

    $this->msg_cnt = imap_num_msg($this->conn); 

    $in = array(); 
    for($i = 1; $i <= $this->msg_cnt; $i++) { 
     $in[$i] = array(
      'index'  => $i, 
      'header' => imap_headerinfo($this->conn, $i), 
      'body'  => imap_body($this->conn, $i), 
      'structure' => imap_fetchstructure($this->conn, $i) 
     ); 
     if(property_exists($in[$i]['header'], 'subject')){ 
      $header = $in[$i]['header']; 
      $subject = $header->subject; 
      echo $subject; 
     } 

    } 
    $this->inbox = $in; 
} 
+0

[]内の配列$に切り替えられましたが、まだ何もありません – agates

+0

メソッドを完全に私のものに置き換えましたか?あなたは私が修正したいくつかの問題がありました。 – gview

+1

それはgviewを助けたかもしれない。今働いてくれてありがとう。大きな助け – agates

関連する問題