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

Recommended Answers

All 2 Replies

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
}

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.