Go Back   Dreamweaver Club Forums > Hand Coders Forum > PHP
Register FAQ Members List Search Today's Posts Mark Forums Read

Thread Tools Display Modes
Old 07-16-2012, 12:14 AM   #1
FethrdWlf's Avatar
Join Date: Jan 2011
Location: Arizona
Posts: 146
Question Using preg_match to find if string equals required pattern, or required+optional pattern?

I have buttons at the top of my website that link to other pages of the website (only the first two are in use currently). The toolbar is a single PHP page that I include in every page. In the toolbar page, PHP checks the current directory the user is in, and then either displays a "link button", or a "current page" button, so that the user can see where they are.

I'm running into a problem though. I have an if statement checking the value of a variable that contains the current directory.

PHP Code:
$curdir == "/category/blog/"){...}else{...}
That'll work if the user is in the default directory of the blog, but if they are in let's say "/category/blog/page/3/", it doesn't quite work out. The script needs to check to see that they are definitely at least in the default blog directory, or even deeper in.

I know I can use preg_match to do what I need to do, but I don't know how to do it. Thank you for your time

EDIT: also I'm sure there's a cleaner way to check the directory and display from there, but I'll open a new thread for that if need be.
FethrdWlf is offline   Reply With Quote

Thread Tools
Display Modes

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

Forum Jump

All times are GMT. The time now is 12:27 AM.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2018, vBulletin Solutions, Inc.
Copyright 2006 DreamweaverClub.com