Forum Moderators: coopster
I'm writing a 'breadcrumb' generator and also a table of contents generator using an array containing the structure of my (sub-)site. Something like this:
$site_structure = array (
array ('index.php', 'Widgets', 0),
array ('010000_blue-widgets.php', 'Blue Widgets', 1),
array ('010100_intro.php', 'Introduction', 2),...
I'm testing
$site_structure[n][0] against basename($_SERVER['REQUEST_URI'])
Everything works perfectly, except when I come in on the 'root' of this subdir (eg. [emample.com...]
If I come in on (or navigate using the array) to [emample.com...] it works fine (of course).
Is there something (or some technique) where I can find a match on both "/" and also "/index.php"?
Many thanks, Sam.
$site_structure = array (
array ('/', 'Widgets', 0), // <- line added
array ('index.php', 'Widgets', 0),
array ('010000_blue-widgets.php', 'Blue Widgets', 1),
array ('010100_intro.php', 'Introduction', 2),...
$site_structure[n][0] against basename($_SERVER['REDIRECT_URL'])
This not only behaves the same when encountering "/" and "index.php" ("/" is interpreted by $_SERVER['REDIRECT_URL'] as /index.php) it also works with a query string on the back (which $_SERVER['REQUEST_URI'] does not).
I guess this may be server setup specific but it works fine for me on a pretty standard virtual host.
To answer my own question $_SERVER['REDIRECT_URL'] is not an alternative $_SERVER['REQUEST_URI'], but in this case it's heaps better.