3
Contributors
2
Replies
6
Views
6 Years
Discussion Span
Last Post by fobos
0

You can use the PHP Document Object Model (DOM), an example:

<?php
    $f = '
    <html>
        <head>
            <title>test</title>
        </head>
        <body>
            <div id="aaa">apples</div>
            <div id="bbb">oranges</div>
        </body>
    </html>
        ';
    $dom = new domDocument;
    $dom->loadHTML($f);
    $dom->preserveWhiteSpace = false;
    
    $t = $dom->getElementsByTagName('div');
    $newElement = $t->item(0)->nodeValue; // 0 to display #aaa, 1 for #bbb
    echo $newElement . "\n";
?>
0

Thanks for the help cereal. i was trying to echo the website into $f, then pull the div by id. 1, how do i get the web content into a variable.. like $f = geturlcontent? then call the div. 2, can i use $t = $dom->getElementById($f); to get the div that i want? basically what im trying to do is get stats of players from one website and post it on mine. this way ppl can come to my website and view stats of players and not have to visit the original website

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.