james_4k2 Posted August 7, 2008 Share Posted August 7, 2008 Hi to all, I am a new php programmer and I am stuck with a problem. <?php $f=fopen("http://www.health.gov.on.ca/english/providers/program/ohip/sob/schedule_master.html","r"); ?> My task is to write a script which will go to the above mentioned link and then search for the effective date. Currently if you visit the website then the effective date is June 5, 2008. I also have a database which has current date and new date column. so my script should search this website everyday and match it with the database. If the new effective date is different from current date stored in db then it should change the current date. I have tried a lot of things and then came across regex so if some one can help me out or give me a direction to move then I will be very greatfull. Thanks in advance Quote Link to comment Share on other sites More sharing options...
nrg_alpha Posted August 7, 2008 Share Posted August 7, 2008 $str = file_get_contents('http://www.health.gov.on.ca/english/providers/program/ohip/sob/schedule_master.html'); preg_match('#effective[^\.]*#', $str, $match); echo $match[0]; This is a bare bones method that basicaly gets the file contents from the url listed in the $str variable and seeks out from the word 'effective' and stops when it hits a period. So the result would be: effective June 5, 2008 If you don't want the 'effective' part, you can simply use a positive look behind assertion: $str = file_get_contents('http://www.health.gov.on.ca/english/providers/program/ohip/sob/schedule_master.html'); preg_match('#(?<=effective)[^\.]*#', $str, $match); echo $match[0]; The result will be: June 5, 2008 Is this what you seek? Cheers, NRG Quote Link to comment Share on other sites More sharing options...
james_4k2 Posted August 7, 2008 Author Share Posted August 7, 2008 thanks a lot nrg_alpha. U saved me. have a nice day 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.