0

Running parse_url() on :

This kind of URLs : http://mondomom.com extracts successfully mondomom.com and returns it as host.

This kind of URLs : http://www.mondomom.com/?sdfdsfsd=dsdfsdf extracts successfully mondomom.com and returns it as host.

But on this kind of URLs : http://www.mondomom.com/sdasdasd/sdad the parse_url() function can not find the domain. It seems that it is only designed to work with URL that have query strings in them

Is there a way to extract the correct domain from the latter ?

Alucard
  • 1,814
  • 1
  • 21
  • 33
  • 2
    It works perfectly for me. `var_dump(parse_url('http://www.mondomom.com/sdasdasd/sdad'));` produces: `array(3) { 'scheme' => string(4) "http" 'host' => string(16) "www.mondomom.com" 'path' => string(14) "/sdasdasd/sdad" }` What version of PHP are you using? Are you sure you're not seeing non-ASCII characters that just look like `/`, etc.? – elixenide Nov 04 '15 at 21:13
  • Would try to explode / and var_dump a array of it, maybe.. and try a preg match for first part http:// getthis/ – Kavvson Empcraft Nov 04 '15 at 21:29

0 Answers0