0

ok what i am trying to do is see if multiple values are all yes.


idk if what i think is right, actually is right.

$1 = "yes";
$2 = "yes";
$3 = "no";

if ( ($1 && $2 && $3) == "yes" ) {
	$thing = "you";
} else {
	$thing = "me";
}

thanks in advance

2
Contributors
2
Replies
3
Views
8 Years
Discussion Span
Last Post by itisnot_me
0

Doesn't quite work that way. There are hacks you can do but in general you'll want something along these lines

$var1 = 'yes';
$var2 = 'yes';
$var3 = 'no';
if ($var1 == 'yes' && $var2 == 'yes' && $var3 == 'yes') {
  // do something
} else {
  // do something else
}

The hacky way being

$var1 = 'yes';
$var2 = 'yes';
$var3 = 'no';
$vars = array($var1, $var2, $var3);
if ($vars === array_fill(0, count($vars), 'yes')) {
  // do something
} else {
  // do something else
}
0

you are a life saver. i know i can count on you to help. well that is if you can.

i like doing things the proper way

thanks alot

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.