是否可以在laravel中更改字符串:
"这是字符串" 到" this-is-string " ?
在laravel doc中。我只发现了这个:
$ snake = snake_case(' fooBar');
// foo_bar
非常感谢你的帮助:))
答案 0 :(得分:7)
如果你想在Laravel中这样做,你可以打电话:
Str::slug('This Is String');
有关详细信息,请访问API:http://laravel.com/api/source-class-Illuminate.Support.Str.html#247-270
答案 1 :(得分:3)
我不认识Laravel,但你可以试试这个:
<?php
$string = "This Is String"
$string = strtolower(str_replace(" ", "-", $string)); // "this-is-string"
?>
答案 2 :(得分:2)
试试这个:
return Str::slug('This Is String');
//这-是字符串
doc:http://three.laravel.com/docs/strings / http://laravel.com/api/source-class-Illuminate.Support.Str.html#247-270