Parsing a folder name from a URL
Posted: Wed Nov 05, 2003 8:21 am
I think this comes under the "don't laugh" section for regulars and professionals. 
Basically I'm in the process of designing a site which isn't particularly deep (folder-wise), and so I thought it would be nice to have one of those Home > Folder > This Page lines on each page, much like you can see above here. The "Home" link remains static, and the "This Page" display is defined from page to page. However what I would like to do is generate the "Folder" link dynamically instead of having to define that on each page as well.
I was then planning to match up the result with corresponding entries in a MySql database to show on the display.
I did take a look in the manual, but upon further looking at preg_match I realised I was looking at completely the wrong thing. I've looked at preg_match, and preg_replace, neither seems to be the right thing to use. Would preg_split be a better way to go, or is there something which makes the whole thing easier?
Basically I'm in the process of designing a site which isn't particularly deep (folder-wise), and so I thought it would be nice to have one of those Home > Folder > This Page lines on each page, much like you can see above here. The "Home" link remains static, and the "This Page" display is defined from page to page. However what I would like to do is generate the "Folder" link dynamically instead of having to define that on each page as well.
Code: Select all
$thispage = $PHP_SELF;
// gives you /directory/page.php
$thisdir = substr($thispage, 1);
// gives you directory/page.php
// then I need something to elimate the /page.php sectionI did take a look in the manual, but upon further looking at preg_match I realised I was looking at completely the wrong thing. I've looked at preg_match, and preg_replace, neither seems to be the right thing to use. Would preg_split be a better way to go, or is there something which makes the whole thing easier?