•  0
    PHP

    PHP function to convert HTML to symbol characters

      Asmin Jismun    287        0        Report content

    function ConvertHTMLToSymbolCharacters($string) {
    
        $fixed_str= htmlspecialchars_decode($string, ENT_QUOTES);
    
        $trans_array = array();
        for ($i=32; $i<=255; $i++) {
            $trans_array["&#" . $i . ";"] = chr($i);
        }
    
        $fixed_str = str_replace("´","’",$fixed_str);
        $fixed_str = str_replace("–","–",$fixed_str);
        $fixed_str = str_replace("…","…",$fixed_str);
        $fixed_str = str_replace("’","'",$fixed_str);
        $fixed_str = str_replace("â„¢",chr(0x99),$fixed_str); //
        $fixed_str = str_replace(" "," ",$fixed_str); //
        $fixed_str = str_replace("®",chr(0xAE),$fixed_str); //®
        $fixed_str = str_replace("™",chr(0x99),$fixed_str); //™
        $fixed_str = str_replace("©",chr(0xA9),$fixed_str); //©
        $fixed_str = str_replace("£",chr(0xA3),$fixed_str); //£
        $fixed_str = str_replace("¢",chr(0xA2),$fixed_str); //¢
        $fixed_str = str_replace("¥",chr(0xA5),$fixed_str); //¥
        $fixed_str = str_replace("&","&",$fixed_str); // ampersand
            
        $fixed_str = str_replace("	","",$fixed_str); //horizontal tab
        $fixed_str = str_replace("Œ",chr(0x152),$fixed_str); //Œ
        $fixed_str = str_replace("œ",chr(0x153),$fixed_str); //œ
        $fixed_str = str_replace("Š",chr(0x160),$fixed_str); //Š
        $fixed_str = str_replace("š",chr(0x161),$fixed_str); //š
        $fixed_str = str_replace("Ÿ",chr(0x178),$fixed_str); //š
        $fixed_str = str_replace("ƒ",chr(0x192),$fixed_str); //ƒ
        $fixed_str = str_replace("–",chr(45),$fixed_str); //–
        $fixed_str = str_replace("—",chr(0x2014),$fixed_str); //—
        $fixed_str = str_replace("‘",chr(0x2018),$fixed_str); //‘
        $fixed_str = str_replace("’",chr(0x2019),$fixed_str); //’
        $fixed_str = str_replace("‚",chr(0x201A),$fixed_str); //‚
    
        $fixed_str = str_replace("“",'"',$fixed_str);
        $fixed_str = str_replace("”",'"',$fixed_str);
        $fixed_str = str_replace("„",chr(0x201E),$fixed_str); //„
        $fixed_str = str_replace("†",chr(0x2020),$fixed_str); //†
        $fixed_str = str_replace("‡",chr(0x2021),$fixed_str); //‡
        $fixed_str = str_replace("•",chr(0x2022),$fixed_str); //•
        $fixed_str = str_replace("…",chr(0x2026),$fixed_str); //…
        $fixed_str = str_replace("‰",chr(0x2030),$fixed_str); //‰
        $fixed_str = str_replace("€",chr(0x20AC),$fixed_str); //€
    
        $fixed_str = str_replace("™",chr(0x99),$fixed_str); //™
        $fixed_str = str_replace("・",chr(0xB7),$fixed_str);//
        
        $fixed_str = str_replace("´",chr(0xB4),$fixed_str);
        
        $fixed_str_final = strtr($fixed_str, $trans_array);
        return $fixed_str_final;
    }

     


  •  


Leave a Comment

Please Login to insert comment.

 

Facebook Conversations