$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
上面的代码将产生以下内容:
Pokémon = pokemon
YO MAN! = yo-man
我想重写它以提高效率,并在此后不久将其转换为函数。
我怎样才能使用多个,preg_replace()
所以这不会是一个多行代码?