I have a HTML form field $_POST[\"url\"]
having some URL strings as the value.
Example values are:
https://example.com/test/1234?email=xyz@test.com
I created function from @Ruel answer. You can use this:
function get_valueFromStringUrl($url , $parameter_name)
{
$parts = parse_url($url);
if(isset($parts['query']))
{
parse_str($parts['query'], $query);
if(isset($query[$parameter_name]))
{
return $query[$parameter_name];
}
else
{
return null;
}
}
else
{
return null;
}
}
Example:
$url = "https://example.com/test/the-page-here/1234?someurl=key&email=xyz5@test.com";
echo get_valueFromStringUrl($url , "email");
Thanks to @Ruel