Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP - Extracting text from HTML

Tags:

html

php

I have a long string of HTML that contains

<p>
<img>
<span> 

and a bunch of other tags.

Is there anyway of extracting ONLY the text within the tags from this string?

like image 794
Dan Avatar asked Dec 23 '22 05:12

Dan


1 Answers

If you want to extract all text within any tags, the simple way is to strip the tags: strip_tags()

If you want to remove specific tags, maybe this SO questions helps.

like image 190
Pekka Avatar answered Dec 24 '22 17:12

Pekka