public static function makeSafe($str, $strict = false, $extrachars = '')
    {
        $str = str_replace('&amp;', '', $str);

        $delim = '/';
        if ($extrachars != '') {
            $extrachars = preg_quote($extrachars, $delim);
        }
        if ($strict) {
            $slugify = Slugify::create([
                'regexp' => '/[^a-z0-9_' . $extrachars . ' -]+/'
            ]);
            $str = $slugify->slugify($str, '');
            $str = str_replace(' ', '-', $str);
        } else {
            // Allow Uppercase and don't convert spaces to dashes
            $slugify = Slugify::create([
                'regexp' => '/[^a-zA-Z0-9_.,' . $extrachars . ' -]+/',
                'lowercase' => false
            ]);
            $str = $slugify->slugify($str, '');
        }

        return $str;
    }
public static function makeSafe($str, $strict = false, $extrachars = '')
    {
        $str = str_replace('&amp;', '', $str);

        $delim = '/';
        if ($extrachars != '') {
            $extrachars = preg_quote($extrachars, $delim);
        }
        if ($strict) {
            $slugify = Slugify::create([
                'regexp' => '/[^a-z0-9_' . $extrachars . ' -]+/'
            ]);
            $str = $slugify->slugify($str, '');
            $str = str_replace(' ', '-', $str);
        } else {
            // Allow Uppercase and don't convert spaces to dashes
            $slugify = Slugify::create([
                'regexp' => '/[^a-zA-Z0-9_.,' . $extrachars . ' -]+/',
                'lowercase' => false
            ]);
            $str = $slugify->slugify($str, '');
        }

        return $str;
    }
public static function makeSafe ( $ str , $ strict = false , $ extrachars = '' ) { $ str = str_replace ( '&amp;' , '' , $ str ) ; $ delim = '/' ; if ( $ extrachars != '' ) { $ extrachars = preg_quote ( $ extrachars , $ delim ) ; } if ( $ strict ) { $ slugify = Slugify :: create ( [ 'regexp' => '/[^a-z0-9_' . $ extrachars . ' -]+/' ] ) ; $ str = $ slugify -> slugify ( $ str , '' ) ; $ str = str_replace ( ' ' , '-' , $ str ) ; } else { // Allow Uppercase and don't convert spaces to dashes $ slugify = Slugify :: create ( [ 'regexp' => '/[^a-zA-Z0-9_.,' . $ extrachars . ' -]+/' , 'lowercase' => false ] ) ; $ str = $ slugify -> slugify ( $ str , '' ) ; } return $ str ; }
Returns a "safe" version of the given string - basically only US-ASCII and
numbers. Needed because filenames and titles and such, can't use all characters.

@param string $str
@param bool   $strict
@param string $extrachars

@return string
Returns a safe version of the given string - basically only US - ASCII and numbers . Needed because filenames and titles and such can t use all characters .