简单 HTML DOM 从 <div> 标签获取属性

Simple HTML DOM get attribute from <div> tag

我正在尝试获取的 'tel' 属性,但无法获取。

<div class="horizontal-center" ng-class="classActive()" ng-click="clicked($event)" id="7076213" account-id="536423" user-id="651772" event-label="listing-detail" event-action="phone-number-viewed-in-sideways" tel="8503128272" action-type="DetailPhone">

我正在尝试使用这些代码。 1.

foreach ($html1->find('div.horizontal-center') as $phone) {
 echo   $ilanlar['phone'] = $phone->{'tel'};
}

2.

foreach ($html1->find('div.horizontal-center') as $phone) {
 echo   $ilanlar['phone'] = $phone->getattribute('tel');
}
include('simple_html_dom.php');


$html1 = str_get_html('<div class="horizontal-center" ng-class="classActive()" ng-click="clicked($event)" id="7076213" account-id="536423" user-id="651772" event-label="listing-detail" event-action="phone-number-viewed-in-sideways" tel="8503128272" action-type="DetailPhone">');

foreach ($html1->find('div.horizontal-center') as $phone) {
    echo $ilanlar['phone'] = $phone->{'tel'};
}

echo '<br>'; 

foreach ($html1->find('div.horizontal-center') as $phone) {
    echo $ilanlar['phone'] = $phone->getattribute('tel');
}

对我来说很好用。输出为:

8503128272<br>8503128272