Skip to content

Instantly share code, notes, and snippets.

@connrs
Created January 20, 2011 15:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save connrs/788066 to your computer and use it in GitHub Desktop.
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
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