用 simple.html.dom 抓取并将结果放入数组中

Scraping with simple.html.dom and placing the results into an array

我不知道我的标题是否正确,请随时纠正我,但我有一个简单的问题。我的代码工作正常,我得到了我想要的结果,但我希望它们在一个数组中。例如:[0] => Description: Sentinel. Winged Guardian cannot have restricted attachments. Forced: After an attack in which Winged Guardian defends resolves, pay 1 Tactics resource or discard Winged Guardian from play.

[1] => Description: Attach to a hero. Attached hero gains +1 Attack. Action: Pay 1 resource from attached hero's pool to attach Dunedain Mark to another hero.

这是我的代码:

include 'simple_html_dom.php';

$url="http://hallofbeorn.com/LotR?CardSet=The+Hunt+for+Gollum";
$html=file_get_html($url);

   foreach ($html->find('div[style="margin-left:2px;vertical-align:top;text-align:left;"]') as $values) {
        echo $values->plaintext;
    }

我想这就是您要找的:

include 'simple_html_dom.php';

$url="http://hallofbeorn.com/LotR?CardSet=The+Hunt+for+Gollum";
$html=file_get_html($url);

$html_arr = [];

foreach ($html->find('div[style="margin-left:2px;vertical-align:top;text-align:left;"]') as $values) {
           $html_arr[] = $values->plaintext;
         }

print_r($html_arr);