我收到了一封电子邮件,其主题是今日最后一天☛另外品牌额外32%的折扣,但当我查看它的标题主题行看起来像 -
Subject: =?utf-8?Q?Last=20Day=20Today=E2=98=9B=20An=20Additional=2032%=20Off=20Your=20?=
=?utf-8?Q?Favourite=20Brands.?=
如果我使用imap_headerinfo()获取主题的值,那我该怎么解码这个值。
答案 0 :(得分:3)
imap_mime_header_decode
将为您效劳,即
<?php
$text = "=?utf-8?Q?Last=20Day=20Today=E2=98=9B=20An=20Additional=2032%=20Off=20Your=20?=
=?utf-8?Q?Favourite=20Brands.?=";
$elements = imap_mime_header_decode($text);
var_dump($elements); //will print array values for you
这里有更多细节PHP IMAP Header decode
答案 1 :(得分:3)
您也可以尝试mb_decode_mimeheader();这可能适合您。
答案 2 :(得分:1)
<?php
print_r(imap_mime_header_decode('=?utf-8?Q?Last=20Day=20Today=E2=98=9B=20An=20Additional=2032%=20Off=20Your=20?=
=?utf-8?Q?Favourite=20Brands.?='));
Array
(
[0] => stdClass Object
(
[charset] => utf-8
[text] => Last Day Today☛ An Additional 32% Off Your
)
[1] => stdClass Object
(
[charset] => utf-8
[text] => Favourite Brands.
)
)
答案 3 :(得分:0)
在字符串上使用imap_mime_header_decode()。
答案 4 :(得分:0)
iconv_mime_decode()-解码MIME标头字段