garyjames82 Posted February 19, 2008 Share Posted February 19, 2008 I am a complete newb, and I have tried honest I have. I am trying to pull a random quote from a webpage to put in my own page. As far as I know the following should do that, but it does not work. Please help. <?php $data = file_get_contents("http://www.bbc.co.uk/comedy/reddwarf/factbox/index.shtml"); preg_match("/send.*?Suggestion/", $data, $matches); echo $matches[0]; ?> Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted February 19, 2008 Share Posted February 19, 2008 Do you get any errors? How does it not work? Ken Quote Link to comment Share on other sites More sharing options...
garyjames82 Posted February 19, 2008 Author Share Posted February 19, 2008 Sorry I should have known better Notice: Undefined offset: 0 in /data/www/gazj/dwarf.php on line 4 Quote Link to comment Share on other sites More sharing options...
garyjames82 Posted February 19, 2008 Author Share Posted February 19, 2008 Anybody please Quote Link to comment Share on other sites More sharing options...
garyjames82 Posted February 19, 2008 Author Share Posted February 19, 2008 ok it works with a /s like this preg_match("/send.*?Suggestion/s", $data, $matches); But then it shows the words send. and Suggestion Quote Link to comment Share on other sites More sharing options...
mysterbx Posted February 26, 2008 Share Posted February 26, 2008 did you try curl for getting the content from the other page? 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.