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
Old 04-18-2009, 04:15 AM Php If
Novice Talker

Posts: 14
Name: Wade
Trades: 0
Code:
if ($adminmodule == 'home'){
}
How would i add more == ''?
Instead of
Code:
if ($adminmodule == 'home'){
}
elseif ($adminmodule == 'pages'){
}
elseif ($adminmodule == 'settings'){
}
The three == are home, pages and settings

Any solutions ?
Thanks,
Wade
amphtech is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 04-18-2009, 05:03 AM Re: Php If
nayes84's Avatar
Extreme Talker

Latest Blog Post:
Difference between ASP And JSP
Posts: 232
Name: John
Location: Tokyo
Trades: 0
you can use switch instead of if statement


PHP Code:
switch ($adminmodule)
{
    case 
'home':
    {
         break;
    }
    case 
'pages':
    {

         break;
    }
    case 
'settings':
    {

         break;
    }

__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE

if(I'm("Helpful")) Add_Talkupation("nayes84");

Last edited by nayes84; 04-18-2009 at 05:05 AM..
nayes84 is offline
Reply With Quote
View Public Profile
 
Old 04-18-2009, 01:43 PM Re: Php If
NullPointer's Avatar
Will Code for Food

Posts: 2,783
Name: Matt
Location: Irvine, CA
Trades: 0
Are you trying to do the same thing for each, or something different for each?

If it is the latter do this:
PHP Code:
if($adminmodule == 'home' || $adminmodule == 'pages' || $adminmodule == 'settings')
{


|| is or
&& is and
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
NullPointer is online now
Reply With Quote
View Public Profile Visit NullPointer's homepage!
 
Old 04-18-2009, 03:18 PM Re: Php If
lizciz's Avatar
Webmaster Talker

Posts: 744
Name: Mattias Nordahl
Location: Sweden
Trades: 0
Or you can specify an array of allowed values, and check if the input is in the array.
PHP Code:
$allowed = array('home''pages''settings');
if (
in_array($adminmodule$allowed)) {
   
// ...

This aproach is simpler if you have many values, rather than having to write alot of if/else cases or use alot of || and &&. In your case, however, any method is fine.
__________________
34343639363436653237373432303635373837303635363337 34323037343638363137343263323036343639363432303739 366637353366
lizciz is online now
Reply With Quote
View Public Profile Visit lizciz's homepage!
 
Old 04-18-2009, 09:11 PM Re: Php If
Novice Talker

Posts: 14
Name: Wade
Trades: 0
Thanks I tryed them all, they all worked.
amphtech is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Php If
 

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.15636 seconds with 12 queries