$fileSyntax = strtolower(preg_replace('~&([a-z]{1,2})(acute|cedil|circ|grave|lig|orn|ring|slash|th|tilde|uml);~i', '$1', htmlentities($fileSyntax, ENT_QUOTES, 'UTF-8'))); // remove foreign character accents
$fileSyntax = preg_replace("/[^a-zA-Z0-9\s]/", "", $fileSyntax); // remove anything that's not alphanumeric, or a space
$fileSyntax = preg_replace("/\s+/", "-", $fileSyntax); // replace space with hyphen
$fileSyntax = trim($fileSyntax, "-"); // removes prefixing and trailing hyphen
The above code will produce the following:
Pokémon = pokemon
YO MAN! = yo-man
I want to rewrite this for efficiency and convert it into a function soon thereafter.
How can I utilize more than one preg_replace()
so this will not be a multi-line code?