PHP mb_decode_mimeheader() Function
Last Updated :
28 Mar, 2023
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
$header_string = "=?ISO-8859-1?Q?Caf=E9_au_lait?=" ;
$decoded_string = mb_decode_mimeheader( $header_string );
echo $decoded_string ;
?>
|
Output:
Café_au_lait
Example 2: The following code demonstrates the mb_decode_mimeheader() function
PHP
<?php
$headers = [
"=?ISO-8859-1?Q?Caf=E9_au_lait?=" ,
"=?ISO-8859-1?Q?Bj=F6rk?=" ,
"=?ISO-8859-1?Q?M=F6tley_Cr=FCe?=" ,
];
mb_convert_variables( "UTF-8" , "ISO-8859-1" , $headers );
array_walk ( $headers , function (& $value ) {
$value = mb_decode_mimeheader( $value );
});
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
Share your thoughts in the comments
Please Login to comment...