Search
 
SCRIPT & CODE EXAMPLE
 

PHP

php convert accented characters to html entities

public static function remove_accents($string, $german = false)
    {
        // Single letters
        $single_fr = explode(" ", "À Á Â Ã Ä Å Ą Ă Ç Ć Č Ď Đ Ð È É Ê Ë Ę Ě Ğ Ì Í Î Ï İ Ł Ľ Ĺ Ñ Ń Ň Ò Ó Ô Õ Ö Ø Ő Ŕ Ř Š Ś Ş Ť Ţ Ù Ú Û Ü Ů Ű Ý Ž Ź Ż à á â ã ä å ą ă ç ć č ď đ è é ê ë ę ě ğ ì í î ï ı ł ľ ĺ ñ ń ň ð ò ó ô õ ö ø ő ŕ ř ś š ş ť ţ ù ú û ü ů ű ý ÿ ž ź ż");
        $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;
    }
Comment

PREVIOUS NEXT
Code Example
Php :: pivot table in laravel 9 
Php :: php find in array 
Php :: PHP substr — Return part of a string 
Php :: add filter in wordpress 
Php :: how to check if page opened from mobile or desktop 
Php :: laravel pluck multiple columns 
Php :: php = 
Php :: php unset by value 
Php :: parseint php 
Php :: server.php not found 
Php :: PHP XML Expat Parser 
Php :: phpmailer send email to multiple addresses 
Php :: laravel where json array column 
Php :: php throw fatal error 
Php :: laravel repository design pattern 
Php :: laravel eloquent join two models 
Php :: laravel skip a loop if error 
Php :: laravel add parameter to request 
Php :: login as user in laravel from admin panel 
Php :: str_contains — Determine if a string contains a given substring 
Php :: Laravel storage:link not working 
Php :: pusher 
Php :: if php 
Php :: php ?? vs ?: 
Php :: eloquent relationships 
Php :: php array_slice 
Php :: Not Found The requested URL was not found on this server. Apache/2.4.46 (Win64) OpenSSL/1.1.1g PHP/7.4.11 Server at localhost Port 80 
Php :: csv import in laravel 
Php :: google sheets to php equation 
Php :: laravel defining relationship 
ADD CONTENT
Topic
Content
Source link
Name
2+4 =