我从Mailgun webhook(Delivered)获得以下JSON,我需要从中提取主题行。
它们似乎没有遵循典型的键值JSON格式,缺少一堆foreach循环是否有提取此数据的方法?
[["Received", "by luna.mailgun.net with SMTP mgrt 8734663311733; Fri, 03 May 2013 18:26:27 +0000"], ["Content-Type", ["multipart/alternative", {"boundary": "eb663d73ae0a4d6c9153cc0aec8b7520"}]], ["Mime-Version", "1.0"], ["Subject", "Test deliver webhook"], ["From", "Bob <bob@fvrs.org>"], ["To", "Alice <alice@example.com>"], ["Message-Id", "<20130503182626.18666.16540@fvrs.org>"], ["X-Mailgun-Variables", "{\"my_var_1\": \"Mailgun Variable #1\", \"my-var-2\": \"awesome\"}"], ["Date", "Fri, 03 May 2013 18:26:27 +0000"], ["Sender", "bob@fvrs.org"]]
答案 0 :(得分:2)
它不是字典的原因是因为在电子邮件中你可以有不止一次出现相同的标题。
你只是一个循环:
$subject = null;
foreach ($data as $header) {
if ($header[0] == 'Subject') {
$subject = $header[1];
break;
}
}