mht转html代码(php)

            $content_header = "/Content-Transfer-Encoding:(.*?)\n/ims";
            preg_match($content_header,$content,$item_results);
            $bianma=trim($item_results[1]);
            if($bianma == 'quoted-printable'){
                $pregcont = '/content-transfer-encoding: quoted-printable(.+?)content-type: image\/gif; name=logo.gif/is';
                preg_match($pregcont, $content, $conts);
                //print_r($conts[1]);die;
                //进行编码解压
                $contents=quoted_printable_decode($conts[1]);
            }elseif($bianma=="base64"){
                 $pregcont = '/Content-Transfer-Encoding:base64\n\n(.+?)Content-Type:image\/gif/is';
                preg_match($pregcont, $content, $conts);
                //print_r($conts[1]);die;
                $contents=base64_decode($conts[1]);
            }else{
                //  echo '编码失败';
                return false;
            }

你可能感兴趣的:(mht转html代码(php))