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
https://forums.phpfreaks.com/topic/92938-need-regular-expression-help-pls/
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!

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.