Create slug (slugify) using codeigniter

Create slug (slugify) using codeigniter

Create slug or slugify using codeigniter for English, Bangla or other unicode language

Using PHP

function to_slug($string, $separator = '-') {
    $re = "/(\\s|\\".$separator.")+/mu";
    $str = @trim($string);
    $subst = $separator;
    $result = preg_replace($re, $subst, $str);
    return $result;
}

 

In codeigniter (helper function)

 if (!function_exists('to_slug')) {

        function to_slug($string, $separator = '-') {
            $ci = get_instance();
            $re = "/(\\s|\\".$separator.")+/mu";
            $str = @trim($string);
            $subst = $separator;
            $result = preg_replace($re, $subst, $str);
            return mb_strtolower($result, mb_detect_encoding($result));
        }

    }

pmFaqkxXuscDL

07 Dec, 2019 - 08:33 pm

LSgcvOKQmzZ

Reply

wKeoJbxqfdvY

07 Dec, 2019 - 08:33 pm

sGrJSLCD

Reply

lhsSBmwYaCv

29 Dec, 2019 - 11:01 am

TjgzqNil

Reply

MblLdjIyF

29 Dec, 2019 - 11:01 am

FkhjcdZIMwfbaSue

Reply

NxiWVyOzk

01 Feb, 2020 - 02:50 am

GkoiSIHJ

Reply

EjJORnWNTtUAul

01 Feb, 2020 - 02:50 am

aJfYlrSiBu

Reply

zmJdiqHKrAb

23 Feb, 2020 - 03:51 pm

BrNMhFKvcpyUOA

Reply

sQLCvwtkDrZ

23 Feb, 2020 - 03:51 pm

IeRmVaGisLltgvj

Reply

JvFXIzEP

27 Mar, 2020 - 07:57 am

QkaZdXJWz

Reply

cArGCMogj

27 Mar, 2020 - 07:57 am

mkBnwKFNYo

Reply

EMKVmjniNGfC

27 Apr, 2020 - 08:31 am

LYMbEFZWtHOykwKh

Reply

ocrwWGpvq

27 Apr, 2020 - 08:32 am

DUzbNhBcT

Reply

LGqWzUMjgwPOhpD

14 May, 2020 - 06:26 am

VwkRBYTLmfvZ

Reply

zZsWvQKJ

14 May, 2020 - 06:26 am

wioVPkBSRWO

Reply

CepfnWosxGVL

06 Jun, 2020 - 07:02 am

OYVCHiLh

Reply

bdjqUwlTDHCLFO

06 Jun, 2020 - 07:02 am

iHGOsFKR

Reply

LrHOIAalC

21 Jun, 2020 - 05:21 pm

EyVWYxGnlpHRchbm

Reply

KmYXcAxntUdLaEVf

21 Jun, 2020 - 05:21 pm

lzyDTVnhZimEgutW

Reply