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?
Asked
Active
Viewed 1.6k times
7
-
Please describe you question. – Sahil Gulati May 09 '17 at 05:09
-
2Possible duplicate of [Truncate string in Laravel blade templates](http://stackoverflow.com/questions/15012712/truncate-string-in-laravel-blade-templates) – Richard87 May 09 '17 at 05:11
-
This helps, http://stackoverflow.com/a/24902688/6521116 – LF00 May 09 '17 at 05:16
-
I've a string of length more than 100 characters. But only first 10 characters are needed to be display in my blade in laravel 5.2 – Helena Hannah George May 09 '17 at 05:16
4 Answers
12
use str_limit, refer to this post
{{ str_limit($string, $limit = 10, $end = '...') }}
-
Thanks..This is help full. But can u mention the fields inside the () – Helena Hannah George May 29 '17 at 10:59
-
4
10
You can show a part (first 10 characters) of a string using
{{substr($myStr, 0, 10)}}
in laravel blade template.

Shakti Phartiyal
- 6,156
- 3
- 25
- 46
-
1
-
1@HelenaHannahG Glad to help you.. If you need further assistance.. I would love to help. – Shakti Phartiyal May 29 '17 at 11:06
-
1
0
Laravel 9.x.x
If you want to show only the first character of the string, then:
{{substr($str, 0, 1)}}

Lonare
- 3,581
- 1
- 41
- 45
0
You can use Str helper for Laravel.
$converted = Str::substr('The Laravel Framework', 4, 7);
return 'Laravel'

Pirooz Jenabi
- 440
- 5
- 7