By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,374 Members | 2,993 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,374 IT Pros & Developers. It's quick & easy.

cPath if, else - help - Trying to use WILDCARRD, cPath

P: 5
I am very new to PHP hopefully someone can help me I am trying to use a wildcard for a simple "if else" code. I cant seem to figure out how to do this.

e.g.

if($cPath == '1')
{
echo "this table";
}

I am trying to get it so that cPath will display all categories with the number 1

(e.g.
1_1
1_2
1_3
etc)

I’m not sure how I would go about doing this or how to use a wildcard method any help would be great!
Jul 18 '06 #1
Share this Question
Share on Google+
4 Replies


iam_clint
Expert 100+
P: 1,208
can you give us more of the code and where your having the problem what is cpath set to so on.
Jul 18 '06 #2

P: 5
Sure I will try and explain.

cPath is the category ID (eg say I have a page called books cPath would be index.php?cPath=1_16 I only want the categories with 1_XX to show so anything with 2_XX - X_XX shouldn’t show. I was thinking a wildcard method would work just not sure how I would go about doing it.

Thanks for the help!
Jul 18 '06 #3

iam_clint
Expert 100+
P: 1,208
alright as to a wild card theres not really a way i can think of todo it like your trying
substr(cpath, 0, 2) would return 1_ so you could do an if statement to make sure that the left 2 characters of that string is 1_ but you will need to make a loop to have it check each one.
Jul 18 '06 #4

P: 5
I found a way I just used a greater/ lesser range (eg if ($cPath > '1' && $cPath < "1_99")

looks to work thus far.

Thanks for the help!
Jul 18 '06 #5

Post your reply

Sign in to post your reply or Sign up for a free account.