Created
January 21, 2011 17:50
-
-
Save AD7six/790075 to your computer and use it in GitHub Desktop.
standalone i18n slug function
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function cleanstring($input = '', $seperator = '-') { | |
$pattern = '\x00-\x1f\x26\x3c\x7f-\x9f\x{d800}-\x{dfff}\x{fffe}-\x{ffff}'; | |
$pattern .= preg_quote(' \'"/?!<>.$/:;?@=+&%\#', '@'); | |
$return = preg_replace('@[' . $pattern . ']@Su', $seperator, $input); | |
return trim(mb_strtolower(preg_replace('/' . $seperator. '+/', $seperator, $return), 'UTF-8'), $seperator); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
require 'pablo.php'; | |
$input = 'Prostat Artık Kaderiniz Değil !!!'; | |
$expected = 'prostat-artık-kaderiniz-değil'; | |
echo "$input\n"; | |
echo "$expected\n"; | |
echo cleanString($input) . "\n"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment