Answers for "change special characters to html entities in php"

PHP
3

html special characters php

/*  EXAMPLE:	<p>Bed & Breakfast</p>	-->	  <p>Bed &amp; Breakfast</p>  
    & 	&amp;
    " 	&quot; 				(unless ENT_NOQUOTES is set)
    ' 	&#039; or &apos; 	(ENT_QUOTES must be set)
    < 	&lt;
    > 	&gt;				*/

<?php
$new = htmlspecialchars("<a href='test'>Test</a>", ENT_QUOTES);
echo $new; 					// <a href='test'>Test</a>
?>
Posted by: Guest on September-05-2021
0

php convert accented characters to html entities

public static function remove_accents($string, $german = false)
    {
        // Single letters
        $single_fr = explode(" ", "À Á Â Ã Ä Å &#260; &#258; Ç &#262; &#268; &#270; &#272; Ð È É Ê Ë &#280; &#282; &#286; Ì Í Î Ï &#304; &#321; &#317; &#313; Ñ &#323; &#327; Ò Ó Ô Õ Ö Ø &#336; &#340; &#344; Š &#346; &#350; &#356; &#354; Ù Ú Û Ü &#366; &#368; Ý Ž &#377; &#379; à á â ã ä å &#261; &#259; ç &#263; &#269; &#271; &#273; è é ê ë &#281; &#283; &#287; ì í î ï &#305; &#322; &#318; &#314; ñ &#324; &#328; ð ò ó ô õ ö ø &#337; &#341; &#345; &#347; š &#351; &#357; &#355; ù ú û ü &#367; &#369; ý ÿ ž &#378; &#380;");
        $single_to = explode(" ", "A A A A A A A A C C C D D D E E E E E E G I I I I I L L L N N N O O O O O O O R R S S S T T U U U U U U Y Z Z Z a a a a a a a a c c c d d e e e e e e g i i i i i l l l n n n o o o o o o o o r r s s s t t u u u u u u y y z z z");
        $single = array();
        for ($i = 0; $i < count($single_fr); $i++) {
            $single[$single_fr[$i]] = $single_to[$i];
        }
        // Ligatures
        $ligatures = array("Æ" => "Ae", "æ" => "ae", "Œ" => "Oe", "œ" => "oe", "ß" => "ss");
        // German umlauts
        $umlauts = array("Ä" => "Ae", "ä" => "ae", "Ö" => "Oe", "ö" => "oe", "Ü" => "Ue", "ü" => "ue");
        // Replace
        $replacements = array_merge($single, $ligatures);
        if ($german) $replacements = array_merge($replacements, $umlauts);
        $string = strtr($string, $replacements);
        return $string;
    }
Posted by: Guest on March-31-2021

Code answers related to "change special characters to html entities in php"

Browse Popular Code Answers by Language