How to use Str::limit on tinymce contents in laravel

513 views laravel

I want to limit number words using Str::limit() in laravel view but contents of tinymce which are stored in the form of <p><strong >Lorem Ipsum</strong><span >&nbsp;is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</span></p>

I have noticed that am shortening those style when I tried to shorten contents and style of my page become nasty,

How can I shorten tinymce contents in laravel view using Str::limit() or any other php functionality like substr()?

answered question

2 Answers


You can use php function strip_tags to remove the html tags.

{!! str_limit(strip_tags($string), 7) !!}

posted this

I have added 'Str' => Illuminate\Support\Str::class, in my app.config file

and in my laravel view I have applied

{!! Str::words($a->description,40, '...')!!}

Everything work perfectly

posted this

Have an answer?


Please login first before posting an answer.