-2

I can catch current URL by $_SERVER['REQUEST_URI'] which is /mysitw/project/detail/fp/3 & want to parse like

array(0=>mysite, 1=>project, 2=>detail, 3=>fp, 4=>3)

and then easily search my required value using in_array() which I can do if could parse url successfully in an array

2
  • Do you have an actual question? Commented Sep 24, 2012 at 11:54
  • possible duplicate of PHP - strip URL to get tag name Commented Sep 24, 2012 at 13:07

2 Answers 2

3

If you do this...

$array = explode('/', $_SERVER['REQUEST_URI']);

your array should look like this...

echo $array [0]; // mysite
echo $array [1]; // project
echo $array [2]; // detail
echo $array [3]; // fp
echo $array [4]; // 3
Sign up to request clarification or add additional context in comments.

Comments

0
$url = $_SERVER['REQUEST_URI'];
$url_splits = parse_url($url);
$path = $url_splits['path'];

$each_elemts = explode("/",$path);

print_r($each_elemts);

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.