如何在Laravel中对tinymce内容使用Str :: limit

时间:2018-09-16 14:46:40

标签: laravel tinymce

我想在laravel视图中使用Str :: limit()限制数字单词,但tinymce的内容以<p><strong style="margin: 0px; padding: 0px; font-family: 'Open Sans', Arial, sans-serif; text-align: justify;">Lorem Ipsum</strong><span style="font-family: 'Open Sans', Arial, sans-serif; text-align: justify;">&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>的形式存储

当我尝试缩短页面的内容并使样式变得令人讨厌时,我注意到这些样式正在缩短

如何使用Str :: limit()或任何其他php功能(如substr())在laravel视图中缩短tinymce内容?

2 个答案:

答案 0 :(得分:0)

您可以使用php函数strip_tags删除html标签。

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

答案 1 :(得分:0)

我已经在我的app.config文件中添加了'Str' => Illuminate\Support\Str::class,

在我的laravel视图中,我已应用

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

一切正常