trim in laravel code example
Example 1: how to trim string in laravel
{{ \Illuminate\Support\Str::limit($productVal, 20, $end='...') }}
Example 2: how to trim text php
$text = " hello world ";
$text = trim($text);
=> "hello world"
Example 3: laravel trim string blade
#at AppServiceProvider
Blade::directive('trim', function ($string) {
$string = urldecode($string);
$string = trim($string);
return "<?php echo $string; ?>";
});
#And use on Blade template
@trim('Hello world !')