我在一个laravel项目工作.我有一个slu ur的网址.它适用于英语.但是当我使用Bangla时它返回空.请帮我解决这个问题.
echo str_slug("hi there");
// Result: hi-there
echo str_slug("???????? ???????? ????????? ???? ????? ????? ??????????");
// Result: '' (Empty)
Run Code Online (Sandbox Code Playgroud)
Zay*_*Ali 17
str_slug或Facade版本Str::slug不适用于非ascii字符串.您可以使用此方法
function make_slug($string) {
return preg_replace('/\s+/u', '-', trim($string));
}
$slug = make_slug(" ???????? ???????? ????????? ???? ????? ????? ?????????? ");
echo $slug;
// Output: ????????-????????-?????????-????-?????-?????-??????????
Run Code Online (Sandbox Code Playgroud)