Parsing a URL
Posted: Tue Apr 12, 2005 7:19 pm
I have a variable degreetypeid which holds a URL like
$degreetypeid="start3.php?degreetypeid=1°reetype=Associates"
I need to parse this URL to get the value of degreetypeid in the URL which in the above case is 1. The code I have used is as under
But it doesnt seem to work for some reason. Can anyone tell me what the mistake is. Thanks
$degreetypeid="start3.php?degreetypeid=1°reetype=Associates"
I need to parse this URL to get the value of degreetypeid in the URL which in the above case is 1. The code I have used is as under
Code: Select all
<? preg_match("/[degreetypeid]\s*=\s*(.*?)/i", $degreetypeid, $matches);
$degree = $matches[1];
echo $degree;
?>