doudeng9425 2018-01-02 16:35
浏览 72
已采纳

如何在PHP的循环中通过数组键cc和bcc取消设置所有邮件头?

Below is how I tried to unset all the mail header array by cc and bcc.

unset(
  $message['cc'], $message['Cc'], $message['CC'],
  $message['headers']['cc'], $message['headers']['Cc'], $message['headers']['CC'],
  $message['params']['headers']['cc'], $message['params']['headers']['Cc'], $message['params']['headers']['CC'],
  $message['bcc'], $message['Bcc'], $message['BCC'],
  $message['headers']['bcc'], $message['headers']['Bcc'], $message['headers']['BCC'],
  $message['params']['headers']['bcc'], $message['params']['headers']['Bcc'], $message['params']['headers']['BCC']
);

There are cc, Ccc, CCC, bcc, Bcc and BCC. I know the above solution is not efficient. How can I replace the above code with a shorter code using for-loop?

  • 写回答

1条回答 默认 最新

  • dqsvnsad79721 2018-01-02 16:47
    关注

    You can create an array with all the "cc" and "BCC"s and loop it.

    $items = ["cc","Cc","CC","bcc","Bcc","BCC"];
    
    Foreach($items as $item){
        Unset($message[$item],$message['headers'][$item], $message['params']['headers'][$item]);
    }
    

    Not sure if I got them all or missed one, but you get the point.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥50 MATLAB APP 制作出现问题
  • ¥15 wannier复现图像时berry曲率极值点与高对称点严重偏移
  • ¥15 利用决策森林为什么会出现这样·的问题(关键词-情感分析)
  • ¥15 DispatcherServlet.noHandlerFound No mapping found for HTTP request with URI[/untitled30_war_e
  • ¥15 使用deepspeed训练,发现想要训练的参数没有梯度
  • ¥15 寻找一块做为智能割草机的驱动板(标签-stm32|关键词-m3)
  • ¥15 信息管理系统的查找和排序
  • ¥15 基于STM32,电机驱动模块为L298N,四路运放电磁传感器,三轮智能小车电磁组电磁循迹(两个电机,一个万向轮),怎么用读取的电磁传感器信号表示小车所在的位置
  • ¥15 如何解决y_true和y_predict数据类型不匹配的问题(相关搜索:机器学习)
  • ¥15 PB中矩阵文本型数据的总计问题。