Pergunta

in my PHP web application,I have a dataentry form where users will enter data using a rich text editor (FCKEditor i m using) and will be saving the Markup from the editor to the DB table.In another page i have to display the first 200 chars of the content (with View more link to view the entire thing). So when i m taking first 200 chars,the HTM Lmarkup is breaking because i may miss the closing tags of some of the html tags started already.How can i get rid of this ? I know i can use strip_tags to remove all HTML markup.But i wanna keep that as it is.Is there anything which i can do to solve this ?

Foi útil?

Solução

Run it through HTMLTidy as that might help. For example, when you have link tag (a) opened but not closed, that might help to get rid of the link "bleed" to next element. You will still have issues if your script cuts the string from the middle of the tag, a la "<di". It's not fool-proof solution and i wouldn't rely on it.

The best practice imgo is to treat the "short" version of the text separately, just let the user enter it into separate text editor.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top