kejo Posted January 29, 2008 Share Posted January 29, 2008 hello, hope you can help me. i need to get the value: 56.64 out of this string Uploaded:</font> <font color="#cccccc">56.64 GB i tried many and many, but wasnt able to find a good one please help me. thanks, this forum is full of good people! Quote Link to comment Share on other sites More sharing options...
effigy Posted January 29, 2008 Share Posted January 29, 2008 What did you try, and why do you think they failed? <pre> <?php $data = 'Uploaded:</font> <font color="#cccccc">56.64 GB'; preg_match('%(?<=Uploaded:</font> <font color="#cccccc">)([\d.]+)%', $data, $matches); print_r($matches); ?> <pre> Quote Link to comment Share on other sites More sharing options...
kejo Posted January 29, 2008 Author Share Posted January 29, 2008 thanks mate! how come it doesnt work if the $data is an extracted webpage ? $data = file_get_contents('http://www.site.com'); Quote Link to comment Share on other sites More sharing options...
laffin Posted January 29, 2008 Share Posted January 29, 2008 i wudda opted for sumfin like preg_match("@Uploaded:(?:<.*>)(\d{1,}.\d{2}) ([bGMTK]{2})@i",$data,$matches) Quote Link to comment Share on other sites More sharing options...
kejo Posted January 29, 2008 Author Share Posted January 29, 2008 ok guys i got what the problem is: the site i get the value from needs to be logged in: how can i do this in php? i need to access the page and get the value trhu the script... Quote Link to comment Share on other sites More sharing options...
laffin Posted January 30, 2008 Share Posted January 30, 2008 depends on the authentication method cookies or https for https ya can put the username/pw on the url string https://site.com@user:pw/path/ I believe the format is for cookies ya will prolly opt for using curl (as fopen wud be a lot of code) [http://www.weberdev.com/get_example-4555.html]using curl with cookies example[/url] Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.