Friday, October 3, 2025
HomeLanguagesPHP mb_decode_mimeheader() Function

PHP mb_decode_mimeheader() Function

The mb_decode_mimeheader()  function is an inbuilt function in PHP where the string is decoded into the MIME header field.

Syntax:

mb_decode_mimeheader(string $string): string

Parameter: This function has a single parameter:

  • string: This parameter specifies the string that is to be decoded.

Return Value: The decoded string will be returned in internal character encoding.

Example 1: The following code demonstrates the mb_decode_mimeheader() function

PHP




<?php
  
// MIME-encoded header string
$header_string = "=?ISO-8859-1?Q?Caf=E9_au_lait?=";
  
// Decode the header string
$decoded_string = mb_decode_mimeheader($header_string);
  
// Output the decoded string
echo $decoded_string;
?>


Output:

Café_au_lait

Example 2:  The following code demonstrates the mb_decode_mimeheader() function

PHP




<?php
  
// Array of MIME-encoded header strings
$headers = [
    "=?ISO-8859-1?Q?Caf=E9_au_lait?=",
    "=?ISO-8859-1?Q?Bj=F6rk?=",
    "=?ISO-8859-1?Q?M=F6tley_Cr=FCe?=",
];
  
// Decode the header strings
mb_convert_variables("UTF-8", "ISO-8859-1", $headers);
  
array_walk($headers, function (&$value) {
    $value = mb_decode_mimeheader($value);
});
  
// Output the decoded strings
var_dump($headers);
?>


Output:

array(3) {
   [0]=> string(13) "Café_au_lait"
   [1]=> string(6) "Björk"
   [2]=> string(13) "Mötley_Crüe"
}

Reference: https://www.php.net/manual/en/function.mb-decode-mimeheader.php

Dominic
Dominichttp://wardslaus.com
infosec,malicious & dos attacks generator, boot rom exploit philanthropist , wild hacker , game developer,
RELATED ARTICLES

Most Popular

Dominic
32332 POSTS0 COMMENTS
Milvus
85 POSTS0 COMMENTS
Nango Kala
6703 POSTS0 COMMENTS
Nicole Veronica
11868 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11929 POSTS0 COMMENTS
Shaida Kate Naidoo
6819 POSTS0 COMMENTS
Ted Musemwa
7080 POSTS0 COMMENTS
Thapelo Manthata
6775 POSTS0 COMMENTS
Umr Jansen
6776 POSTS0 COMMENTS