| |||||||
| Programming PHP, Perl, Ruby on Rails, AJAX, HTML, XHTML, CSS, JavaScript, MySQL and any other coding topics. |
![]() |
| | LinkBack | Thread Tools |
| | #1 (permalink) |
| Soon to be RICHdoggie! | php if - is this possible? is it possible to do something like this in php? PHP Code: PHP Code: Tom |
| |
| | #5 (permalink) |
| Soon to be RICHdoggie! | i just really couln't be bothered to write it out full, and if there was a shorter way I would rather have used that. Also, I can't make use of the switch thing because it needs to be if $var == any of these values then do this, otherwise dont. switch would just take too long. Thanks anyhow Tom |
| |
| | #6 (permalink) |
| NamePros Regular | no, but why not just make a function out of it. Code: function or($var,$var1,$var2,$var3) {
if($var == "$var2" || $var == "$var2" || $var == "$var3") return true;
else return false;
}
if (or($var1,"blah","blah","blah")) {
} else { }
|
| |
| | #9 (permalink) | ||
| Soon to be RICHdoggie! | Quote:
thanksQuote:
| ||
| |
| | #10 (permalink) |
| NamePros Regular | Nice one Scott. Nested if's Code: if($var == "something") {
if($var == "blah") {
if($var == "something else") {
}
}
} else { }
![]() Code: function or($var) {
for($c=1;$c>count($c);++$c) {
if($var[0] != $var[$c]) { return false }
}
return true;
}
if(or(array($v,"sweet","shivy","something else"))) { echo "sweet"; }
else { echo "dude"; }
- Last edited by bliss; 08-27-2006 at 07:36 AM. |
| |
| | #11 (permalink) |
| I'll do it Technical Services | PHP Code:
__________________ Vhuv|Delq|Fhur|Twut|Tluz|Kegh|Vhir|Juhy|Ruuz|Jyos|Jupt|Vhek Webmaster Blog | Software Downloads Sponsor Ads at SponAds.com |
| |
| | #13 (permalink) |
| Soon to be RICHdoggie! | lol.. thanks for that. I never knew that was called nested ifs! and tree is right, it dosen't solve it. Its not that big a deal, lol, although thanks for all your help. I was really just wondering if php had the capabilities built in to do something like that, rather than having to write it out in full. Just to save time, lol ![]() Anyhow, thanks a lot everyone. Your scripts and solutions have been most interesting, and in fact some have helped me in other ways! ![]() Thanks Tom |
| |
| | #17 (permalink) |
| I'll do it Technical Services | I always go with nested IF's even if it is more then 25 IF's Switch is also good. But sometimes I get confused in it. And IF's are coming out in some kind of rhythym. So it does all the work without thinking how and hey, what to write for the switch.
__________________ Vhuv|Delq|Fhur|Twut|Tluz|Kegh|Vhir|Juhy|Ruuz|Jyos|Jupt|Vhek Webmaster Blog | Software Downloads Sponsor Ads at SponAds.com |
| |
| | #18 (permalink) | |
| NamePros Regular | I misread the original question Quote:
Last week I used a nested switches for the first time in a long time. As long as you comment everything and tab the code properly it becomes less confusing ;p | |
| |
| | #19 (permalink) | |
| Soon to be RICHdoggie! | Quote:
PHP Code: | |
| |
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| |