开发者

how do i get this data into some form of manageable array?

http://pastebin.com/raw.php?i=BBr7XCtS

I have no idea where to start, there isn't any form of class/id and I can't figure out how to regex it. Hoping to get it into a multidimensional array or something. ($array[place] would contain the 开发者_高级运维names of whichever teams, etc)

HTML regexes are failing anytime it encounters a tied vs single...

edit: okay, regex and xml isn't helping me at all :|


You can try SimpleXML - it'll move the structure of the HTML to a nice format. You will have to make sure that:
- You don't have any fragments at the beginning - in the example you gave, the first tag is a </ul>
- You wrap the entire thing in a root node

$data = '<rootnode>
              <dt><br />In 179th place with 2,755 points is </dt>
              <dd>
                <ul>
                  <li>DIAL&#160;NINE:&#160;IS&#160;ANYONE&#160;PLAYING&#160;WITH&#160;US?</li>
                </ul>
              </dd>
        </rootnode>';

$xml = new SimpleXMLElement($xmlstr);
//each dt can be accessed with
foreach ($xml->dt as $dt) {
  echo $dt;
}

//each dd can be accessed with
foreach ($xml->dd as $dd) {
  echo $dd;
}

//And etc

http://www.php.net/manual/en/simplexml.examples-basic.php


I would suggest multipass. First pass to divide into Tied and singles. Second pass to split up tieds.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜