user1603136
user1603136

Reputation:

How to get HTML content of a DIV in PHP

I need to get the HTML content of a DIV from the URL. I've already try to get the content of the div with preg_match() and simple_html_dom but I've only get the plain text.

Example with simple_html_dom :

$html = file_get_html('http://webpage.tld');
$code = $html->find('#mydiv', 0);
var_dump($code->plaintext);

Upvotes: 4

Views: 6595

Answers (1)

Lim H.
Lim H.

Reputation: 10050

Instead of $code->plaintext use $code->outertext

Upvotes: 4

Related Questions