note 51862 deleted from function.strtr by googleguy

From: Date: Tue, 22 Oct 2013 10:17:53 +0000
Subject: note 51862 deleted from function.strtr by googleguy
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-196986@lists.php.net to get a copy of this message
Note Submitter: info at oscaralexander dot com ---- Here's a nice function for parsing a string to something suitable for URL rewriting (mod_rewrite). It translates all accented characters to their non-accented equivalents and replaces all other non-alphanumeric character with dashes: function getRewriteString($sString) { $string = htmlentities(strtolower($string)); $string = preg_replace("/&(.)(acute|cedil|circ|ring|tilde|uml);/", "$1", $string); $string = preg_replace("/([^a-z0-9]+)/", "-", html_entity_decode($string)); $string = trim($string, "-"); return $string; }

« previous php.notes (#196986) next »