Skip to content

Instantly share code, notes, and snippets.

@devi
Created March 23, 2011 15:14
Show Gist options
  • Save devi/883260 to your computer and use it in GitHub Desktop.
Save devi/883260 to your computer and use it in GitHub Desktop.
<?php defined('SYSPATH') OR die('No direct script access.');
class Valid extends Kohana_Valid {
public static function slug($str)
{
if (preg_match('/^[a-zA-Z0-9_-]+$/D', $str, $matches))
{
// Strip multiple dashes and trim an ending or starting dashes
return ($str === preg_replace('/-{2,}/', '-', trim($matches[0], '-')));
}
return FALSE;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment