Autolycus Autolycus - 1 year ago 134
PHP Question

How to get parameters from a URL string?

I have a HTML form field

having some URL strings as the value.
Example values are:


How can I get only the
parameter from these URLs/values?

Please note that I am not getting these strings from browser address bar.

Answer Source

You can use the parse_url() and parse_str() for that.

$parts = parse_url($url);
parse_str($parts['query'], $query);
echo $query['email'];

If you want to get the $url dynamically with PHP, take a look at this question:

Get the full URL in PHP

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