phpdomsimple-html-dom

Simple HTML Dom: How to remove elements?


I would like to use Simple HTML DOM to remove all images in an article so I can easily create a small snippet of text for a news ticker but I haven't figured out how to remove elements with it.

Basically I would do

  1. Get content as HTML string
  2. Remove all image tags from content
  3. Limit content to x words
  4. Output.

Any help?


Solution

  • There is no dedicated methods for removing elements. You just find all the img elements and then do

    $e->outertext = '';