Home » Php » html – Laravel Limit Characters – PHP

html – Laravel Limit Characters – PHP

Posted by: admin July 12, 2020 Leave a comment

Questions:

I used this line of code to show next post title on my app

<span class="blog-title-next"> {{ $post->nextPost()['title'] }} </span>

How can I limit the title name to show only first 10 characters?

Thanks.

How to&Answers:

You could use the str_limit() helper function:

{{ str_limit($post->nextPost()['title'], 10) }}