7

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?

4 Answers4

12

use str_limit, refer to this post

{{ str_limit($string, $limit = 10, $end = '...') }}
Community
  • 1
  • 1
LF00
  • 27,015
  • 29
  • 156
  • 295
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
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