[英]How to get element like eg. h1 from data passed to view
I have to fetch one element from data passed to view. 我必须从传递给视图的数据中获取一个元素。 I have div with content like this:
我有div这样的内容:
<div class="disc" id="content">
{!! $clause->contents !!}
</div>
It shows some text where i have element with heading 1 - h1. 它显示了一些文本,其中我有标题为1 - h1的元素。 How can I fetch only this h1 element which I could use in somewhere else in view?
我怎样才能获取我可以在视图中的其他地方使用的这个h1元素?
Better practice would be to have additional column for that heading in your database. 更好的做法是在数据库中为该标题添加额外的列。 Eg.
例如。
$clause->title
or $clause->heading
, but since you're dealing with that problem you will have to extract that heading through DOM parser. $clause->title
或$clause->heading
,但由于你正在处理这个问题,你必须通过DOM解析器提取该标题。
You can find detailed solution to this on this question which you can integrate into your controller. 您可以在此问题上找到详细的解决方案,您可以将其集成到控制器中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.