我使用簡單的HTML DOM來提取用戶幻想足球隊。我想要做的是在下面的源代碼中獲得每個玩家的「ID」號碼。因此,例如在下面的「ID」的股利是121使用簡單的HTML DOM來提取ID
<div id="ismGraphical1" class='ismPitchElement {"coptr": null, "played": 0, "pos": 1, "can_sub": 1, "ep_this": 4.5, "event_points": 2, "id": 121, "sub": 0, "m": 1, "copnr": null, "is_captain": false, "team": 6, "is_vice_captain": false, "type": 1, "ep_next": 4.5} '>
下面的代碼返回整個DIV,但我想只得到了ID。我試過使用嵌套for循環,但它不工作。我認爲這與div內的數組有關。但不知道從哪裏開始。如果任何人都可以在右側直接指向我,我將不勝感激
$html = new simple_html_dom($result);
foreach($html->find('div.ismPitchElement') as $pitchview)
echo $pitchview;
對不起,我誤解了 – hek2mgl
已經更新了答案。你可以用更少的代碼完成你所看到的。 – hek2mgl
Thx ..沒問題:) – hek2mgl