使用简单html dom PHP时获得第一个

使用简单html dom PHP时获得第一个,php,simple-html-dom,Php,Simple Html Dom,我正在使用来选择外部页面的某些部分 我已经成功地掌握了以下内容 $result=$html->find('#边栏bgbtm.data',0)->outertext 但问题是,#边栏bgbtm 我怎样才能选择第一个元素呢?我想这个链接可以帮助您 元素$e->first_child()您已经得到了它$html->find(“#sidebar bgbtm.data”)返回所有找到的元素的数组,$html->find(“#sidebar bgbtm.data”,$index)将仅返回由$index指定的

我正在使用来选择外部页面的某些部分

我已经成功地掌握了以下内容
$result=$html->find('#边栏bgbtm.data',0)->outertext

但问题是,
#边栏bgbtm

我怎样才能选择第一个元素呢?

我想这个链接可以帮助您


元素$e->first_child()

您已经得到了它
$html->find(“#sidebar bgbtm.data”)
返回所有找到的元素的数组,
$html->find(“#sidebar bgbtm.data”,$index)
将仅返回由
$index
指定的元素,在您的情况下,
0
将获取第一个元素。。。