sam sam - 1 year ago 88
PHP Question

Is there a PHP function for retrieving the "first part" of a URL?

Is there a PHP function for retrieving the "first part" of a URL, similar to how

dirname
/
basename
act on file paths?

Something along the lines of

echo "url_basename('example.com/this_post/12312')"


which would return

example.com

Answer Source

parse_url should do this reliably.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download