Skip to content

Instantly share code, notes, and snippets.

@clement006
Last active December 25, 2015 00:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save clement006/6885942 to your computer and use it in GitHub Desktop.
Save clement006/6885942 to your computer and use it in GitHub Desktop.
<?php
/**
* Formats string, removes accents from string
* @param string $string String to format
* @return string
*/
function strip_accent($string)
{
$accents = '/&([A-Za-z]{1,2})(grave|acute|circ|cedil|uml|lig);/';
$string_encoded = htmlentities($string, ENT_NOQUOTES, 'UTF-8');
$string = preg_replace($accents, '$1', $string_encoded);
return $string;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment