Need to extract digits from URL in browser
Posted: Tue Jun 09, 2009 7:01 pm
Hello Everyone
I am trying to extract 2-3 digits long from the browser url.
For example:
My url: http://www.xxx.com/category/15/Automobiles.html
I am trying to extract the value within the URL 15 and place it in a variable via php.
I am familiar with the following code however I don't know how to strip out the unneeded charters.
The site name and "category" will remain constant. The digits and text after that are variable.
displays...
http://the_url.com/the_path_and_file_name
Could someone please point me in the right direction on how to do this?
I am trying to extract 2-3 digits long from the browser url.
For example:
My url: http://www.xxx.com/category/15/Automobiles.html
I am trying to extract the value within the URL 15 and place it in a variable via php.
I am familiar with the following code however I don't know how to strip out the unneeded charters.
The site name and "category" will remain constant. The digits and text after that are variable.
Code: Select all
<?
$url = $_SERVER['SERVER_NAME'];
$page = $_SERVER['php_SELF'];
echo "http://".$url.$page;
?>
http://the_url.com/the_path_and_file_name
Could someone please point me in the right direction on how to do this?