Answers for "slugify text in php"

PHP
0

slugify text in php

function slugify($text)
    {
        $text = preg_replace('~[^\pLd]+~u', '-', $text);
        $text = trim($text, '-');
        $text = strtolower($text);
        //$text = preg_replace('~[^-w]+~', '', $text);
        if (empty($text))
            return 'n-a';
        return $text;
    }
Posted by: Guest on February-17-2022

Browse Popular Code Answers by Language