Forum Moderators: coopster
$urlarray = explode("/", "/about/new/index.php");
print_r($urlarray);
...returning this...
Array ( [0] => [1] => about [2] => new [3] => index.php )
Perhaps I am being dense but why do I have an extra empty value at the beginning of the array? I was expecting only 3 items.
Is there any way I can make it return the ones I want (ie only those containing an actual value) or do I simply have to work around this?
Removing the first backslash will give you the result you are looking for. $urlarray[0] is the empty value before the first backslash, so removing it will remove the $urlarray[0].
It should be like this:
$urlarray = explode("/", "about/new/index.php");
print_r($urlarray);
Habtom
$url = substr($_SERVER['PHP_SELF'],1);
that will return the string minus the first char