Created
January 20, 2011 15:41
-
-
Save connrs/788066 to your computer and use it in GitHub Desktop.
Pinched from mariano/syrup/models/behaviors/sluggable.php for my own sluggable behaviour using CakePHP's core Inflector class to do the work
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
if (!empty($settings['ignore'])) { | |
$words = array(); | |
foreach((array) $settings['ignore'] as $word) { | |
$words[] = preg_quote($word); | |
} | |
$newString = preg_replace('/\b(\s*)(' . implode('|', $words) . ')(\s*)\b/i', '\\1\\3', $string); | |
if (!empty($newString)) { | |
$string = $newString; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment