Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

laravel slug for non-english words too

// Slugs for non-english words too
Laravel str_slug method in order to work with non-english words too. For example chaning ñ to n and ç to c. I always use this method for this kind of conversion:

function slugify($string, $replace = '-')
{
    $removeasci = iconv('UTF-8', 'ASCII//TRANSLIT', $string);
    $removecomas = str_replace(''', '', $removeasci);
    $output = preg_replace('/[^a-zA-Z0-9]/', $replace, $removecomas);

    return strtolower($output);
}
Source by github.com #
 
PREVIOUS NEXT
Tagged: #laravel #slug #words
ADD COMMENT
Topic
Name
1+1 =