0
在使用smarty模板的文章网站上,我需要截断主要内容以创建预告片。我可以通过字符截断,但第一段的长度是完全未知的文章。 我想要的东西更聪明,只是表明第一段:将内容截断为Smarty的第一段
内容:
This is my first paragraph and I want to display this and only this.
This the rest of the content and it is very long with a lot of words...
预告:
This is my first paragraph and I want to display this and only this.
感谢您指出我朝着正确的方向。 使用这个我可以解决我的问题的第二部分,如何隐藏我的内容第一段取出多后旗: '{*删除第一个段落*}' '{的preg_replace('/ ^。 *?<\/p> /是','',$ content)}' 但是我试图只显示第一段失败。 您在上面发布的代码仅显示“三次(我的内容有3段) 删除多行标志只显示一个”和另一段落。 '{preg_replace('/^.*?<\/p>/is','$ 1“',$ content)}' –