使用Simple HTML DOM Parser获取h2 html

问题描述 投票:0回答:1

我有这个代码的HTML网页:

<div class="col-sm-9 xs-box2">
    <h2 class="title-medium br-bottom">Your Name</h2>
</div>

现在我想使用Simple HTML DOM Parser在这个div中获取h2的文本值。我的代码是:

$name = $html->find('h2[class="title-medium br-bottom"]');
echo $name;

但它总是会返回错误:“

Notice: Array to string conversion in C:\xampp\htdocs\index.php on line 21
Array

我该如何解决这个错误?

php simple-html-dom
1个回答
© www.soinside.com 2019 - 2024. All rights reserved.