Reputation: 1944
is it possible in laravel to change string like this:
"This Is String" to "this-is-string" ?
In laravel doc. I have only found this:
$snake = snake_case('fooBar');
// foo_bar
Thank you very much for your help :)
Upvotes: 1
Views: 4244
Reputation: 64
try this :
return Str::slug('This Is String');
//this-is-string
doc : http://three.laravel.com/docs/strings / http://laravel.com/api/source-class-Illuminate.Support.Str.html#247-270
Upvotes: 2
Reputation: 2319
I don't know Laravel but you can try this :
<?php
$string = "This Is String"
$string = strtolower(str_replace(" ", "-", $string)); // "this-is-string"
?>
Upvotes: 3
Reputation: 3664
If you want to do it in Laravel though, you could call:
Str::slug('This Is String');
For more info visit API: http://laravel.com/api/source-class-Illuminate.Support.Str.html#247-270
Upvotes: 7