Jump to content

need regular expression help, pls


ivytony

Recommended Posts

<?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 ;)

 

 

Link to comment
Share on other sites

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!

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.