giorgio79 giorgio79 -4 years ago 559
PHP Question

php: Get plain text from html - simplehtmldom or php strip_tags?

I am looking at getting the plain text from html. Which one should I choose, php strip_tags or simplehtmldom plaintext extraction?

One pro for simplehtmldom is support of invalid html, is that sufficient in itself?

Answer Source

You should probably use smiplehtmldom for the reason you mentioned and that strip_tags may also leave you non-text elements like javascript or css contained within script/style blocks

You would also be able to filter text from elements that aren't displayed (inline style=display:none)

That said, if the html is simple enough, then strip_tags may be faster and will accomplish the same task

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download