- Get a specific part of the current url.
- Break URL in part by slash ‘/’.
- Get every section of URL by slash ‘/’
1 2 3 4 5 6 7 8 9 | $url = $_SERVER['REQUEST_URI']; /* http://something.com/product/shirt/zara $parts = explode('/', $url); $page3 = $parts[count($parts) - 3]; $page2 = $parts[count($parts) - 2]; $page1 = $parts[count($parts) - 1]; echo "$page1"; /* zara */ echo "$page2"; /* shirt */ echo "$page3"; /* product */ |