Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
PHP for 'current page' indicators on menus?
Old 04-28-2005, 07:52 AM
Experienced Talker

Posts: 43
Trades: 0
I just realized that I may run into some problems with the pages generated by Expression Engine. Possibly, it will not work at all, but it will definitely get into trouble with the folders.

Would it be possible to change

Code:
$folders = substr($url,0,strrpos($url,"/"));
so that it always cuts off at /Section/SubSection/? I imagine it might be easiest to do the cut-off with a slash, so I could always add the slashes to the end of the array entries, but I don't know if it is possible to limit the string in that fashion.
Linda is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 04-28-2005, 07:31 PM
0beron's Avatar
Defies a Status

Posts: 1,832
Location: Somewhere else entirely
Trades: 0
It is certainly possible, and can be done in a number of ways. Probably simplest is to use the explode function:

PHP Code:
$url $_SERVER['PHP_SELF'];

$parts explode("/",$url);

$two_folders_only "/".$parts[1]."/".$parts[2]; 
To explain the above:
explode converts a string into an array, dividing it into bits around the character you specify, in this case '/' . So in the above example, if $url were to be '/Citadel/FAQ/Part1/display.php', $parts would be an array with element 0 ='', 1='Citadel', 2='FAQ', 3='Part1', 4='display.php'. (Arrays start from 0, and the first element is the empty string, since $url starts with /, the character we are using as the divider)

The bits of it you want are always in element 1 and 2, so you can pick those out, add in a couple of slashes and you have the first two folders but no more, no matter how many there might be. The full stop is used to join strings in PHP.
__________________
UPDATE 0beron SET talkupation = talkupation + lots WHERE post = 'helpful';

Please login or register to view this content. Registration is FREE
(aka MSN handwriting for forums)
0beron is offline
Reply With Quote
View Public Profile Visit 0beron's homepage!
 
Old 04-29-2005, 05:45 AM
Experienced Talker

Posts: 43
Trades: 0
Great, that should do it.
Linda is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to PHP for 'current page' indicators on menus?

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.36233 seconds with 11 queries