Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

regular expressions 1

Status
Not open for further replies.

missippi

IS-IT--Management
Feb 8, 2001
42
US
I am trying use a regular expression to determine which menus get displayed.

eregi("^/([a-z0-1_/~]+)/.*$", $REQUEST_URI, parsedRequest);
$menu = $parsedRequest[1];

How do I changes this to obtain "admin" from the url below

This is the $REQUEST_URI
as per looking at my phpinfo()
/~mao2222/php/admin/default.php

Thanks!

MAO
 
Probably easiest to use preg_match:

// the \b in the pattern indicates a word boundary, so only the distinct
// word is matched, and not a word partial like "badminton"
if (preg_match ("/\badmin\b/i", $REQUEST_URI)) {
print "A match was found.";
} else {
print "A match was not found.";
}
***************************************
Party on, dudes!
[cannon]
 
KarveR:

dosnt your rexeg also match 'admin.htm'?

I liked r.j.b.groot@kub.nl's note because its universality. cu, Sascha
 
Reading the poriginal post it seems missippi (IS/IT--Manageme) wants to obtain the word admin from the requested URL ... oddly mine will get that. ***************************************
Party on, dudes!
[cannon]
 

What I am trying to do is include a different menu file depending on what section of my site people request.

I have serveral sections and one is admin another is faculty.

It looks like my question was answered and I made it worked.

Thanks for you assistance.

MAO
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top