LaravelBook\Laravel4Powerpack\Str::slug PHP Метод

slug() публичный Метод

Returns "this-is-my-blog-post" $slug = Str::slug('This is my blog post!'); Returns "this_is_my_blog_post" $slug = Str::slug('This is my blog post!', '_');
public slug ( string $title, string $separator = '-', $keepExtension = false ) : string
$title string
$separator string
Результат string
    public function slug($title, $separator = '-', $keepExtension = false)
    {
        $title = $this->ascii($title);
        // Remove all characters that are not the separator, letters, numbers, or whitespace.
        $title = preg_replace('![^' . preg_quote($separator) . '\\pL\\pN\\s]+!u', '', $this->lower($title));
        // Replace all separator characters and whitespace by a single separator
        $title = preg_replace('![' . preg_quote($separator) . '\\s]+!u', $separator, $title);
        return trim($title, $separator);
    }