I am trying to replace accented characters with the normal replacements. Below is what I am currently doing.
$string = "Éric Cantona";
$strict = strtolower($string);
echo "After Lower: ".$strict;
$patterns[0] = '/[á|â|à|å|ä]/';
$patterns[1] = '/[ð|é|ê|è|ë]/';
$patterns[2] = '/[í|î|ì|ï]/';
$patterns[3] = '/[ó|ô|ò|ø|õ|ö]/';
$patterns[4] = '/[ú|û|ù|ü]/';
$patterns[5] = '/æ/';
$patterns[6] = '/ç/';
$patterns[7] = '/ß/';
$replacements[0] = 'a';
$replacements[1] = 'e';
$replacements[2] = 'i';
$replacements[3] = 'o';
$replacements[4] = 'u';
$replacements[5] = 'ae';
$replacements[6] = 'c';
$replacements[7] = 'ss';
$strict = preg_replace($patterns, $replacements, $strict);
echo "Final: ".$strict;
This gives me:
After Lower: éric cantona
Final: ric cantona
The above gives me ric cantona I want the output to be eric cantona.
can anyone help me with where I am going wrong?
Your Answer
0 answers
Hot tools Tags
Hot Questions
Merging arrays with the same keys
2026-01-05 22:43:11
What is the difference between HTTP_HOST and SERVER_NAME in PHP?
2026-01-05 22:21:40
What's the simplest way of detecting keyboard input in a script from the terminal?
2026-01-05 22:01:05
How to copy/create derived class instance from a pointer to a polymorphic base class?
2026-01-05 21:43:19
How to check a radio button with jQuery?
2026-01-05 21:21:13
Popular tool
vc9-vc14 (32+64 bit) runtime library collection (link below)
Download the collection of runtime libraries required for phpStudy installation
VC9 32-bit
VC9 32-bit phpstudy integrated installation environment runtime library
PHP programmer toolbox full version
Programmer Toolbox v1.0 PHP Integrated Environment
VC11 32-bit
VC11 32-bit phpstudy integrated installation environment runtime library
SublimeText3 Chinese version
Chinese version, very easy to use
Hot Topics
Douyin level price list 1-75
20417
7
20417
7
wifi shows no ip assigned
13577
4
13577
4
Hot Article
How to set up price alerts so you don't miss key entry points?
2026-01-01
By DDD
Why do professional traders advise newbies to start with low leverage?
2026-01-01
By DDD
How to Fix a 'KERNEL_DATA_INPAGE_ERROR' on Windows?
2026-01-02
By 下次还敢
How to reverse a string in Python? (code examples)
2025-12-31
By 下次还敢






