php - Preg match where id attribute changes by 1 -


i want innertext of each anchor. , print results. "ctl" in id attribute increased 01 each time though.

i have match them id attribute because of page these anchors located.

how that?

<a id="ctl00_maincontent_rpleaderboard_ctl01_hypservicerecord" href="/stats/reach/default.aspx?player=dj+darkrecon">dj darkrecon</a>  <a id="ctl00_maincontent_rpleaderboard_ctl02_hypservicerecord" href="/stats/reach/default.aspx?player=x+pr+legacy+x">x pr legacy x</a>  <a id="ctl00_maincontent_rpleaderboard_ctl03_hypservicerecord" href="/stats/reach/default.aspx?player=forgiver2">forgiver2</a> 

here rather quick solution using html parser:

$dom = new domdocument; $dom->loadhtml(' <!doctype html>  <a id="ctl00_maincontent_rpleaderboard_ctl01_hypservicerecord" href="/stats/reach/default.aspx?player=dj+darkrecon">dj darkrecon</a> <a id="ctl00_maincontent_rpleaderboard_ctl02_hypservicerecord" href="/stats/reach/default.aspx?player=x+pr+legacy+x">x pr legacy x</a> <a id="ctl00_maincontent_rpleaderboard_ctl03_hypservicerecord" href="/stats/reach/default.aspx?player=forgiver2">forgiver2</a> '); $i = 1;  while($i < 4) {     var_dump($dom->getelementbyid("ctl00_maincontent_rpleaderboard_ctl0{$i}_hypservicerecord")->nodevalue);     $i++; } 

there numerous ways go via parser, i'm hoping give sort of start.


Comments

Popular posts from this blog

linux - Mailx and Gmail nss config dir -

c# - Is it possible to remove an existing registration from Autofac container builder? -

php - Mysql PK and FK char(36) vs int(10) -