Tuesday, March 21, 2017

Shorten a string but maintaining html code consistant

I have a field on my DB, that saves a HTML code.

When I am showing it, I want to cut the string in about 200 characteres.

But I don't want to cut a in the middle of it.

How could I do that?

EDIT:

I was using "str_limit($string, 200)" helper function from Laravel.

I would like it to identify if it started an HTML tag before, it has to close it.



via dante

Advertisement