2

Slug function is working perfectly in English but when I try to put Bangla it showing only ---

now showing:

input title: Top চাঁ mom কিন্তু মৈত্রী (কালো এলাচ)

output slug: top---mom----------

Need to show this way

input title: Top চাঁ mom কিন্তু মৈত্রী (কালো এলাচ)

output slug: Top-চাঁ-mom-কিন্তু-মৈত্রী-কালো-এলাচ


here below is my php function of slug in my blog.... how to fix this ???

function slug($text){ 
  // replace non letter or digits by -
  $text = preg_replace('~[^\\pL\d]+~u', '-', $text);
  // trim
  $text = trim($text, '-');
  // transliterate
  $text = iconv('utf-8', 'us-ascii//TRANSLIT', $text);
  // lowercase
  $text = strtolower($text);
  // remove unwanted characters
  $text = preg_replace('~[^-\w]+~', '', $text);
  if (empty($text))
  {
    return 'n-a';
  }
  return $text;
}

2 Answers2

0

use this package for bangla slug for php laravel site Sohibd Bangla slug

-1

use mb_strtolower() to for the lower case of the string. And for preg_replace, follow this link.

Hope, it will work.

Amimul Ehshan
  • 192
  • 1
  • 12