Using WordPress ‘remove_accents()’ PHP function

The remove_accents() WordPress PHP function converts all accent characters to ASCII characters. If there are no accent characters, the given string is returned unchanged.

Usage

$converted_string = remove_accents( $string );

Example:
Input: Régulièrement
Output: Regulierement

Parameters

  • $string (string): The input string containing accent characters to be converted.

More information

See WordPress Developer Resources: remove_accents

Examples

Convert a string with accent characters

Convert a string containing accent characters to a string with ASCII characters.

$text = "Élégance";
$converted_text = remove_accents( $text );
// Output: "Elegance"

Convert a string with special currency symbols

Replace currency symbols with corresponding ASCII characters.

$currency = "20,00€";
$converted_currency = remove_accents( $currency );
// Output: "20,00E"

Convert a string with Latin-1 Supplement characters

Convert a string containing Latin-1 Supplement characters.

$latin_text = "Tradição";
$converted_latin_text = remove_accents( $latin_text );
// Output: "Tradicao"

No conversion for strings without accent characters

If the string doesn't have any accent characters, it will be returned unchanged.

$normal_text = "Hello World!";
$converted_normal_text = remove_accents( $normal_text );
// Output: "Hello World!"

Convert a string with mixed accent and ASCII characters

Convert a string containing a mix of accent and ASCII characters.

$mixed_text = "Café au lait";
$converted_mixed_text = remove_accents( $mixed_text );
// Output: "Cafe au lait"