/    Sign up×
Community /Pin to ProfileBookmark

How to get a snippet from URL

Hello,

I wonder how to get a snippet from a url.

For example:

If the url = domain.com/Menu_item_1 the menu has to be …

[B]Menu item 1[/B] – Menu item 2 – Menu item 3

… but if the url = domain.com/Menu_item_3 the menu has to be …

Menu item 1 – Menu item 2 – [B]Menu item 3[/B]

So I thought to add an .active css class to the menu item which is active according to the URL … or isn’t it the best way to accomplish this?

I’m rather a beginner so I don’t know the conventional way to do stuff like this? But I’m eager to learn ?

Christophe

to post a comment
PHP

3 Comments(s)

Copy linkTweet thisAlerts:
@MindzaiMar 14.2010 — I would probably do this via mod_rewrite and have the value written to a query string variable. Otherwise you could explode() $_SERVER['REQUEST_URI'] and use in_array() to check if the part is in the URL.
Copy linkTweet thisAlerts:
@DaiLaughingMar 14.2010 — If the file is in the root then PHP_SELF would just be the file name.
Copy linkTweet thisAlerts:
@Christophe27authorMar 14.2010 — Thank you for your responses! ?
×

Success!

Help @Christophe27 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.29,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...