Revision: 5047
Updated Code
at February 7, 2008 07:57 by sammy
Updated Code
function CleaningAString($string) { //$string = strtolower($string); // Fix german special chars $string = preg_replace('/[äÄ]/', 'ae', $string); $string = preg_replace('/[üÜ]/', 'ue', $string); $string = preg_replace('/[öÖ]/', 'oe', $string); $string = preg_replace('/[ß]/', 'ss', $string); // Replace other special chars $specialCharacters = array( '#' => 'sharp', '$' => 'dollar', '%' => 'prozent', //'percent', '&' => 'und', //'and', '@' => 'at', '.' => 'punkt', //'dot', '€' => 'euro', '+' => 'plus', '=' => 'gleich', //'equals', '§' => 'paragraph', ); while (list($character, $replacement) = each($specialCharacters)) { $string = str_replace($character, '-' . $replacement . '-', $string); } $string = strtr($string, "ÀÃÂÃÄÅà áâãäåÒÓÔÕÖØòóôõöøÈÉÊËèéêëÇçÌÃÃŽÃìÃîïÙÚÛÜùúûüÿÑñ", "AAAAAAaaaaaaOOOOOOooooooEEEEeeeeCcIIIIiiiiUUUUuuuuyNn" ); // Remove all remaining other unknown characters $string = preg_replace('/[^a-zA-Z0-9\-]/', '-', $string); $string = preg_replace('/^[\-]+/', '', $string); $string = preg_replace('/[\-]+$/', '', $string); $string = preg_replace('/[\-]{2,}/', '-', $string); return $string; }
Revision: 5046
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at February 7, 2008 07:55 by sammy
Initial Code
function FormatAsKey($string) { //$string = strtolower($string); // Fix german special chars $string = preg_replace('/[äÄ]/', 'ae', $string); $string = preg_replace('/[üÜ]/', 'ue', $string); $string = preg_replace('/[öÖ]/', 'oe', $string); $string = preg_replace('/[ß]/', 'ss', $string); // Replace other special chars $specialCharacters = array( '#' => 'sharp', '$' => 'dollar', '%' => 'prozent', //'percent', '&' => 'und', //'and', '@' => 'at', '.' => 'punkt', //'dot', '€' => 'euro', '+' => 'plus', '=' => 'gleich', //'equals', '§' => 'paragraph', ); while (list($character, $replacement) = each($specialCharacters)) { $string = str_replace($character, '-' . $replacement . '-', $string); } $string = strtr($string, "ÀÃÂÃÄÅà áâãäåÒÓÔÕÖØòóôõöøÈÉÊËèéêëÇçÌÃÃŽÃìÃîïÙÚÛÜùúûüÿÑñ", "AAAAAAaaaaaaOOOOOOooooooEEEEeeeeCcIIIIiiiiUUUUuuuuyNn" ); // Remove all remaining other unknown characters $string = preg_replace('/[^a-zA-Z0-9\-]/', '-', $string); $string = preg_replace('/^[\-]+/', '', $string); $string = preg_replace('/[\-]+$/', '', $string); $string = preg_replace('/[\-]{2,}/', '-', $string); return $string; }
Initial URL
Initial Description
Wandelt eine Zeichenkette, die Sonderzeichen enthält, in eine Zeichenkette ohne Sonderzeichen. Converts a string, the special characters contains in a string without special characters.
Initial Title
Cleaning a string
Initial Tags
Initial Language
PHP