php - How to limit the text's height (or the number of lines) that's generated by WYSIWYG editor? -


I have a form that allows user input product details, and in the list page, I want to print (just a few lines)

But there are html tags in the description, I have tried some solutions, but they can not solve my problem.

(Example: If I shorten the text using the sub string function, but it will be the problem with the tag)

You can do quick tag stripping, and add an ellipseas to the end for additional decoration:

  function small ($ text, $ Length) {$ text = trim (strip_tags ($ text)); $ TextLen = strlen ($ text); If ($ textLen & lt; $ length) {return text $; } And {$ text = substr ($ text, 0, $ length); $ Text = '& Amp; Hellip; '; Return $ text; }}   

Be careful that is not correct and if you have made html tags defective, then it may mess up the text, but it is a " Quick and dirty "solution; Otherwise, you will need to parse the html with a suitable device (for example DOMDocument, or better parser) and then your substr ()

Comments

Popular posts from this blog

Python SQLAlchemy:AttributeError: Neither 'Column' object nor 'Comparator' object has an attribute 'schema' -

java - How not to audit a join table and related entities using Hibernate Envers? -

mongodb - CakePHP paginator ignoring order, but only for certain values -