Avatar of Robert Granlund
Robert Granlund
Flag for United States of America asked on

PHP Variables Great Than Less Than

If I have a variable that has a lot of comma separated numbers.
$var = '594,458,458,458,40,40,488,488,200,40,40,80,120,200,514,5';

And I have two other variables that I want to compare it against
$var_a = "475";
$var_b = "450";

And I want to write the following;
if($var contains a number that is Less than or equal to <= $var_a AND contains a number that is greater than or equal to $var_b) {
 $my_new_var = "TRUE";
}
I'm not surre how to write that
PHP

Avatar of undefined
Last Comment
Robert Granlund

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
Dan Craciun

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Robert Granlund

ASKER
I have the following but I don't think it is correct.
It is always echoing "HELLO"
$wave = $row['wavelength'];
   			$wave = explode(', ', $wave);
   			echo'<br />'.$wave[0].'<br />'.$wave[1].'<br />';

   			$a = false;
   			$b = false; 

   			if($wave[0] <= $wave_max) $a = true; 
   			if($wave[1] >= $wave_min) $b = true; 
   			
   			if($a && $b) $wavelength = true;
   			
   			if($wavelength) {
   				echo '<h1>HELLO</h1>';
   			}		

Open in new window

Robert Granlund

ASKER
Never mind my last comment.  That works well.  Thanks.
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck