Php 拉威尔博客文章样本
我正在尝试制作一个系统,将博客文章发布到我的网页上,我可以让它显示数据库中的内容,但是如果我想限制要显示的字符数量的话Php 拉威尔博客文章样本,php,laravel-5,Php,Laravel 5,我正在尝试制作一个系统,将博客文章发布到我的网页上,我可以让它显示数据库中的内容,但是如果我想限制要显示的字符数量的话 @foreach ($pages as $post) <div class="post"> <h4>{{ $post->title}}</h4> <?php $content = html_entity_decode($post->body);
@foreach ($pages as $post)
<div class="post">
<h4>{{ $post->title}}</h4>
<?php
$content = html_entity_decode($post->body);
?>
<p>{!!html_entity_decode($post->body)!!}</p>
<p>{{ str_limit($content, $limit = 300, $end = '...') }}</p>
<div>
@endforeach
@foreach($post形式的页面)
{{$post->title}
{!!html\u实体\u解码($post->body)!!}
{{str_limit($content,$limit=300,$end='…')}
@endforeach
因此,第一个
标记可以工作,但字符不受限制,第二个将限制字符的数量,但它将与HTML标记一起显示。我刚刚学习了laravel,所以我不确定为什么它不能正常工作。为将来的任何人找到了答案,PHP有一个名为strip_tags()的函数