Search code examples
phproundcube

Decode string into Readable format PHP


Decode The following string to proper human readable string using PHP

=?UTF-8?Q?=F0=9F=8E=81Congratulation_Dear,You_are=5FSelected_for=5FOnline?= =?UTF-8?Q?=F0=9F=8E=81cash=5Floan_upto=F0=9F=8E=8110,000/-?=

Solution

  • Use the PHP function imap_mime_header_decode() to decode it.

    For the string posted in the question it returns this:

    Array
    (
        [0] => stdClass Object
            (
                [charset] => UTF-8
                [text] => 🎁Congratulation Dear,You are_Selected for_Online
            )
    
        [1] => stdClass Object
            (
                [charset] => UTF-8
                [text] => 🎁cash_loan upto🎁10,000/-
            )
    
    )
    

    The unprintable character (U+1F381) represents, according to unicode.org, a "wrapped present". It could look like this if displayed using a font that contains it.