And/Or
Moderator: General Moderators
- tecktalkcm0391
- DevNet Resident
- Posts: 1030
- Joined: Fri May 26, 2006 9:25 am
- Location: Florida
And/Or
How can you do a if statement using and/or any simple way like &| ?
How would you do this:
If $cart = 2 and/or $user = 4
How would you do this:
If $cart = 2 and/or $user = 4
http://www.php.net/manual/en/language.operators.php
If ($cart == 2 && $user = 4)
If ($cart == 2 || $user = 4)
If ($cart == 2 && $user = 4)
If ($cart == 2 || $user = 4)
- tecktalkcm0391
- DevNet Resident
- Posts: 1030
- Joined: Fri May 26, 2006 9:25 am
- Location: Florida
I meant doing them together. is there any simpler way to do if x==y and r==2 and/or 4kaszu wrote:http://www.php.net/manual/en/language.operators.php
If ($cart == 2 && $user = 4)
If ($cart == 2 || $user = 4)
No, you have to do them separately.
Code: Select all
(($x==$y) && (($r==2 || $r==4)))
Last edited by idevlin on Sun Jul 01, 2007 3:16 pm, edited 2 times in total.
Code: Select all
if ($x == $y && ($r == 2 || $r == 4)) {}
if ($x == $y && in_array($r, array(2,4))) {}- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
Code: Select all
$x == $y and $r == 2 || $r == 4Hehe although mine seems to have disappeared?feyd wrote:Same result as what idevlin wrote.Code: Select all
$x == $y and $r == 2 || $r == 4
**EDIT**
Goddamn it, I selected nearly everything and meant to copy it but replaced it with "c" instead. Not quite got the CTRL-C combination right there