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
LVL 8
rgranlundAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Dan CraciunIT ConsultantCommented:
Try this (untested):

$var = '594,458,458,458,40,40,488,488,200,40,40,80,120,200,514,5';
$var_a = "475";
$var_b = "450";

$arr = explode(",", $var);

$a = false;
$b = false;

foreach($arr as $value) {
  if($value <= $var_a) $a = true; 
  if($value >= $var_b) $b = true; 
};

if($a && $b) $my_new_var = true;

Open in new window

HTH,
Dan

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
rgranlundAuthor Commented:
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

rgranlundAuthor Commented:
Never mind my last comment.  That works well.  Thanks.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.