Reputation: 109
I have a description field with more than 100 words,but I need to show only 10 characters on my blade. How can I do this?
Upvotes: 7
Views: 17711
Reputation: 682
You can use Str helper for Laravel.
$converted = Str::substr('The Laravel Framework', 4, 7);
return 'Laravel'
Upvotes: 0
Reputation: 4663
Laravel 9.x.x
If you want to show only the first character of the string, then:
{{substr($str, 0, 1)}}
Upvotes: 0
Reputation: 28529
use str_limit, refer to this post
{{ str_limit($string, $limit = 10, $end = '...') }}
Upvotes: 12
Reputation: 6254
You can show a part (first 10 characters) of a string using
{{substr($myStr, 0, 10)}}
in laravel blade template.
Upvotes: 10