src/Transliterator.php
public function slugify(string $text): string
    {
        $map = $this->getMap();
        $text = str_replace(array_keys($map), array_values($map), trim($text));

        $transliterator = IntlTransliterator::create('Any-Latin; Latin-ASCII; Lower()');

        $text = $transliterator->transliterate($text);
        $text = str_replace('&', 'and', $text);

        return preg_replace(
            ['/[^\w\s]/', '/\s+/'],
            ['', '-'],
            $text
        );
    }
public function slugify(string $text): string
    {
        $map = $this->getMap();
        $text = str_replace(array_keys($map), array_values($map), trim($text));

        $transliterator = IntlTransliterator::create('Any-Latin; Latin-ASCII; Lower()');

        $text = $transliterator->transliterate($text);
        $text = str_replace('&', 'and', $text);

        return preg_replace(
            ['/[^\w\s]/', '/\s+/'],
            ['', '-'],
            $text
        );
    }
public function slugify ( string $ text ) : string { $ map = $ this -> getMap ( ) ; $ text = str_replace ( array_keys ( $ map ) , array_values ( $ map ) , trim ( $ text ) ) ; $ transliterator = IntlTransliterator :: create ( 'Any-Latin; Latin-ASCII; Lower()' ) ; $ text = $ transliterator -> transliterate ( $ text ) ; $ text = str_replace ( '&' , 'and' , $ text ) ; return preg_replace ( [ '/[^\w\s]/' , '/\s+/' ] , [ '' , '-' ] , $ text ) ; }
Create a slug by converting and removing all non-ascii characters.

@param string $text

@return string
Create a slug by converting and removing all non - ascii characters .