Jump to content

variable comparison


wrathican

Recommended Posts

hi there.

my problem is that i have three variables, all of which could be different values (numerical between 1 and 4).

i need to compare these vars to each other to see which has the lowest value (1) because i only actually need one value.

 

i have thought about using an if statement something like this

if var1 or var2 or var3 are equal to 1

actual value is set to one

 

if var1 or var2 or var3 are equal to 2

actual value is set to one

 

if var1 or var2 or var3 are equal to 3

actual value is set to one

 

if var1 or var2 or var3 are equal to 4

actual value is set to four

 

but how do format the condition?

i could do it like this:

if(($var1 == 1) || ($var2 == 1) || ($var3 == 1)){
$actualvalue = 1;
}else if(.........

would that be the best way?

or is there an easier way?

 

Link to comment
https://forums.phpfreaks.com/topic/87612-variable-comparison/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.