Quote:
Originally Posted by Nightmaster
Thanks for your anwers. I tried file_get_contents() and it works fine i guess.
Now, all this is because i want to display current Euro exchange rate from the site of our National Bank (It's allowed). I actually just need a data from <div id="blah"> to be displayed on my page, so i wonder if there's some example of script which can do that? I guess that i must use some kind of search within content i get from url?
Thanks!
|
I knew that you'd ask that question  which is why I included the third and final link in my previous post. Try this, I've used this method and it's extremely easy to understand, because there aren't any complicated regular expressions.
I'll edit this post when I have some hard code you can copy in (that uses preg_match regexs, not the above method)  Be back in a jiffy.
EDIT: Here's some hastily hacked together code that seems to work fine for me.
PHP Code:
<?php
$full_contents = "Hello there, <div id=\"blah\">useful content</div> nope!";
$tagname = 'blah';
$matches=0; preg_match('/<div\s*id="'.$tagname.'">(.+?)<\/div>/i',$full_contents,$matches);
echo $matches[1]; //Should only return 'useful content', because that's what's inside <div id="blah"> ... </div>
?>
And to integrate it with file_get_contents(), just replace the $full_contents variable with your file_get_contents() line. To change the div you're looking for, edit the $tagname variable.
Last edited by Physicsguy; 08-18-2012 at 04:04 PM..
|