Replacing accented character with it’s standard character in PHP

When writing a function to save audio files with a user friendly filename , as well as a regex to remove any unwanted spaces and punctuation, I needed to replace any accented characters with their standard format.

e.g If I was saving a Beyoncé album I needed the ‘é’ in her name to be replaced with an ‘e’.

The following works perfectly:

iconv("utf-8","ascii//TRANSLIT",$filename);

Leave a Reply

Your email address will not be published. Required fields are marked *