如果条件不正常[php,drupal]

时间:2017-07-12 14:36:24

标签: php drupal drupal-7 imap

下面的代码应该打印'It works !!',但它不会这样做(它什么都不打印),也许它与编码/解码值或$ match数组有关。我想知道我哪里出错了。请帮忙!!

function my_module_init(){

  //$hostname,$username, $password are omitted here
   $inbox = imap_open($hostname, $username, $password); 
   $header = array();
   $head = array();
   $MC = imap_check($inbox);

// Fetch an overview for all messages in INBOX
$result = imap_fetch_overview($inbox,"1:{$MC->Nmsgs}",0);
foreach ($result as $overview){
    $hText = imap_fetchbody($inbox, $overview->uid, '0', FT_UID);
    $header = explode("\n", imap_fetchheader($inbox, $overview->uid, FT_UID)); 
    foreach($header as $k=>$v){
            if(preg_match('/^([^:]*):(.*)/',$v, $match)){
             $head[$overview->uid][$match[1]] = $match[2];

            }

}

}
//dsm($head[9690401]['X-Call-ID']); //prints "1074148121_43390920@64.158.162.74"
if($head[9690401]['X-Call-ID'] == "1074148121_43390920@64.158.162.74"){ 
    dsm('It works!!'); 
}

imap_close($inbox);

}

0 个答案:

没有答案