开发者

php simple dom parser returning "Array"

开发者 https://www.devze.com 2023-03-17 06:35 出处:网络
<?php include \'simple_html_dom.php\'; $ur开发者_StackOverflow中文版l = \'http://en.wikipedia.org/wiki/Myst\';
<?php
include 'simple_html_dom.php';
$ur开发者_StackOverflow中文版l = 'http://en.wikipedia.org/wiki/Myst';
$html = file_get_html($url);
echo $html->find('body');
?>

This has been returning "Array" on the browser when I try to ONLY get the contents of the body element


Yes, because there may be many elements that fit that selector, so an array of elements is returned. If you only want the first matching element, use $html->find('body', 0). This is all described in the manual: http://simplehtmldom.sourceforge.net/manual.htm


Maybe try

echo $html->find('body', 0);
0

精彩评论

暂无评论...
验证码 换一张
取 消