parse-url

How to store parse_url as a string in PHP?

Hello again. I have the following code: $array = parse_url($_SERVER['HTTP_REFERER']); $Ur = $array['host']; which displays the domain just fine, but when I use this with sessions, it doesn't work. Also, I tested it with gettype and it returns Null? I thought it was an array? Anywho, how do I go about converting the above $Ur into a...

Can this snippet be further optimized / organized?

From my related question here at SO I've come up with the following PHP snippet: $url = parse_url($url); if (is_array($url)) { $depth = 2; $length = 50; if (array_key_exists('host', $url)) { $result = preg_replace('~^www[.]~i', '', $url['host']); if (array_key_exists('path', $url)) { ...

Parsing out "site.com" from a passed variable in PHP?

I'm passing through a variety of URLs in a global variable called target_passthrough, so the URL of a page might look like: http://www.mysite.com/index.php?target_passthrough=example.com Or something like that. Formats for that variable may be a variety of things such as (minus quotes): "www.example.com" ".example.com" "example.com" ...

check for subdomain in parse_url

Hello, I am trying to write a function to just get the users profile id or username from Facebook. They enter there url into a form then I'm trying to figure out if it's a Facebook profile page or other page. The problem is that if they enter an app page or other page that has a subdomain I would like to ignore that request. Right now...