Last active
December 22, 2015 19:19
-
-
Save jonathantorres/6518925 to your computer and use it in GitHub Desktop.
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
// v1 | |
private function _short_name($str, $replace = array(), $delimiter = '-') | |
{ | |
if (!empty($replace)) { | |
$str = str_replace((array) $replace, ' ', trim($str)); | |
} | |
$str = str_replace(array('ç', 'Ç'), 'c', $str); | |
$clean = iconv('UTF-8', 'ISO-8859-1//TRANSLIT//IGNORE', trim($str)); | |
$clean = preg_replace("/[^a-zA-Z0-9\/_|+ -]/", '', $clean); | |
$clean = strtolower(trim($clean, '-')); | |
$clean = preg_replace("/[\/_|+ -]+/", $delimiter, $clean); | |
return $clean; | |
} | |
// v2 | |
private function _short_name($str, $replace = array(), $delimiter = '-') | |
{ | |
if (!empty($replace)) { | |
$str = str_replace((array) $replace, ' ', trim($str)); | |
} | |
$str = str_replace(array('ç', 'Ç'), 'c', $str); | |
$clean = iconv('UTF-8', 'ASCII//TRANSLIT', trim($str)); | |
$clean = preg_replace("/[^a-zA-Z0-9\/_|+ -]/", '', $clean); | |
$clean = strtolower(trim($clean, '-')); | |
$clean = preg_replace("/[\/_|+ -]+/", $delimiter, $clean); | |
return $clean; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment