Kairu Posted July 23, 2008 Share Posted July 23, 2008 Ok! I have a new project starting and I need a little help. I am creating some images that will change what they display depending on what is in a database. To populate it, I am having users input their username. (This is on a forum) The user will click to a PHP page, which will ask for their username. I want to take the username, and retrieve the source from the page "http://www.gaiaonline.com/p/<username>". I then need to search out the string "/forum/searchposts/" and take the numbers after it, convert them into hex, and then search for the first URL containing that hex value. I dont know where to start with grabbing the source. Or searching within it. The rest I can probably handle. Quote Link to comment Share on other sites More sharing options...
LemonInflux Posted July 23, 2008 Share Posted July 23, 2008 http://www.google.co.uk/search?q=regex&ie=utf-8&oe=utf-8&aq=t&rls=org.mozilla:en-US:official&client=firefox-a ---------------- Now playing: Linkin Park - Ppr:Kut (Cheapshot & Jubacca ft. Rasco & Planet Asia) via FoxyTunes Quote Link to comment Share on other sites More sharing options...
Kairu Posted July 23, 2008 Author Share Posted July 23, 2008 But how would I go about downloading the source to regex it? Quote Link to comment Share on other sites More sharing options...
Wolphie Posted July 23, 2008 Share Posted July 23, 2008 If it was me I'd look into using sockets, however you could just use file_get_contents(). PHP Reference: http://uk.php.net/manual/en/function.file-get-contents.php Quote Link to comment Share on other sites More sharing options...
Kairu Posted July 23, 2008 Author Share Posted July 23, 2008 Well, I finished something that works. I dont know if it is that productive, as it takes a while to finish. Anyone see any improvements I can make? <?php $search = 'http://www.gaiaonline.com/p/' . $_GET['u']; $content = file_get_contents($search); $array = split('"', $content); for($i=0; $i<=count($array); $i++) { if(ereg("/forum/searchposts/", $array[$i]) != false || ereg("/forum/myposts/", $array[$i]) != false) { $temp = $array[$i]; } } $temp = explode('/', $temp); $ID = $temp[3]; $HEX = dechex($ID); for($i=0; $i<=count($array); $i++) { if(ereg($HEX, $array[$i]) != false) { $URL = $array[$i]; } } ?> 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.