ivytony Posted February 25, 2008 Share Posted February 25, 2008 <?php $url = 'http://www.officedepot.com/?url=http://clickme.com?id=pA8dtfFoCs8&postrid=137588.443676&type=2&subid=0'; ?> for this above $url, I would like to get the main domwin and the part after ?url=. Now I can get the domain by using this regular expression <?php preg_match('/([^\.\/]+\.[^\/\.]+)((\/)|($))/', $url, $d); echo $domain = strtolower($d[1])."<br />"; ?> I am wondering how to use regular expression to get the part after ?url=. I apprecate your help Quote Link to comment Share on other sites More sharing options...
Jessica Posted February 25, 2008 Share Posted February 25, 2008 There's a board for regular expresions: ) But if all you need is everything after ?url you can use strpos and substr. Quote Link to comment Share on other sites More sharing options...
ucffool Posted February 25, 2008 Share Posted February 25, 2008 Can you use parse_str() http://www.php.net/manual/en/function.parse-str.php or parse_url() http://www.php.net/manual/en/function.parse-url.php Rather than a regular expression? Quote Link to comment Share on other sites More sharing options...
ivytony Posted February 25, 2008 Author Share Posted February 25, 2008 I don't think I can use parse_str, because there are '&' signs in the part after $url=http://clickme.com?id=pA8dtfFoCs8&postrid=137588.443676&type=2&subid=0'; edit: I figured it out by using parse_url <?php echo parse_url($url, PHP_URL_QUERY); ?> thanks! Quote Link to comment Share on other sites More sharing options...
sasa Posted February 25, 2008 Share Posted February 25, 2008 preg_match patern '/\?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.