<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title>Decode MIME header elements</title> </head> <body><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="function.imap-mailboxmsginfo.html">imap_mailboxmsginfo</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.imap-msgno.html">imap_msgno</a></div> <div class="up"><a href="ref.imap.html">IMAP Functions</a></div> <div class="home"><a href="index.html">PHP Manual</a></div> </div><hr /><div id="function.imap-mime-header-decode" class="refentry"> <div class="refnamediv"> <h1 class="refname">imap_mime_header_decode</h1> <p class="verinfo">(PHP 4, PHP 5)</p><p class="refpurpose"><span class="refname">imap_mime_header_decode</span> — <span class="dc-title">Decode MIME header elements</span></p> </div> <div class="refsect1 description" id="refsect1-function.imap-mime-header-decode-description"> <h3 class="title">Description</h3> <div class="methodsynopsis dc-description"> <span class="type">array</span> <span class="methodname"><strong>imap_mime_header_decode</strong></span> ( <span class="methodparam"><span class="type">string</span> <code class="parameter">$text</code></span> )</div> <p class="para rdfs-comment"> Decodes MIME message header extensions that are non ASCII text (see <a href="http://www.faqs.org/rfcs/rfc2047" class="link external">» RFC2047</a>). </p> </div> <div class="refsect1 parameters" id="refsect1-function.imap-mime-header-decode-parameters"> <h3 class="title">Parameters</h3> <p class="para"> <dl> <dt> <span class="term"><em><code class="parameter">text</code></em></span> <dd> <p class="para"> The MIME text </p> </dd> </dt> </dl> </p> </div> <div class="refsect1 returnvalues" id="refsect1-function.imap-mime-header-decode-returnvalues"> <h3 class="title">Return Values</h3> <p class="para"> The decoded elements are returned in an array of objects, where each object has two properties, <em>charset</em> and <em>text</em>. </p> <p class="para"> If the element hasn't been encoded, and in other words is in plain US-ASCII, the <em>charset</em> property of that element is set to <em>default</em>. </p> </div> <div class="refsect1 examples" id="refsect1-function.imap-mime-header-decode-examples"> <h3 class="title">Examples</h3> <p class="para"> <div class="example" id="example-3366"> <p><strong>Example #1 <span class="function"><strong>imap_mime_header_decode()</strong></span> example</strong></p> <div class="example-contents"> <div class="phpcode"><code><span style="color: #000000"> <span style="color: #0000BB"><?php<br />$text </span><span style="color: #007700">= </span><span style="color: #DD0000">"=?ISO-8859-1?Q?Keld_J=F8rn_Simonsen?= <keld@example.com>"</span><span style="color: #007700">;<br /><br /></span><span style="color: #0000BB">$elements </span><span style="color: #007700">= </span><span style="color: #0000BB">imap_mime_header_decode</span><span style="color: #007700">(</span><span style="color: #0000BB">$text</span><span style="color: #007700">);<br />for (</span><span style="color: #0000BB">$i</span><span style="color: #007700">=</span><span style="color: #0000BB">0</span><span style="color: #007700">; </span><span style="color: #0000BB">$i</span><span style="color: #007700"><</span><span style="color: #0000BB">count</span><span style="color: #007700">(</span><span style="color: #0000BB">$elements</span><span style="color: #007700">); </span><span style="color: #0000BB">$i</span><span style="color: #007700">++) {<br /> echo </span><span style="color: #DD0000">"Charset: </span><span style="color: #007700">{</span><span style="color: #0000BB">$elements</span><span style="color: #007700">[</span><span style="color: #0000BB">$i</span><span style="color: #007700">]-></span><span style="color: #0000BB">charset</span><span style="color: #007700">}</span><span style="color: #DD0000">\n"</span><span style="color: #007700">;<br /> echo </span><span style="color: #DD0000">"Text: </span><span style="color: #007700">{</span><span style="color: #0000BB">$elements</span><span style="color: #007700">[</span><span style="color: #0000BB">$i</span><span style="color: #007700">]-></span><span style="color: #0000BB">text</span><span style="color: #007700">}</span><span style="color: #DD0000">\n\n"</span><span style="color: #007700">;<br />}<br /></span><span style="color: #0000BB">?></span> </span> </code></div> </div> <div class="example-contents"><p>The above example will output:</p></div> <div class="example-contents screen"> <div class="cdata"><pre> Charset: ISO-8859-1 Text: Keld Jørn Simonsen Charset: default Text: <keld@example.com> </pre></div> </div> </div> </p> <p class="para"> In the above example we would have two elements, whereas the first element had previously been encoded with ISO-8859-1, and the second element would be plain US-ASCII. </p> </div> <div class="refsect1 seealso" id="refsect1-function.imap-mime-header-decode-seealso"> <h3 class="title">See Also</h3> <p class="para"> <ul class="simplelist"> <li class="member"> <span class="function"><a href="function.imap-utf8.html" class="function" rel="rdfs-seeAlso">imap_utf8()</a> - Converts MIME-encoded text to UTF-8</span></li> </ul> </p> </div> </div><hr /><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="function.imap-mailboxmsginfo.html">imap_mailboxmsginfo</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.imap-msgno.html">imap_msgno</a></div> <div class="up"><a href="ref.imap.html">IMAP Functions</a></div> <div class="home"><a href="index.html">PHP Manual</a></div> </div></body></html>