We help IT Professionals succeed at work.
Get Started

PHP Variables Great Than Less Than

Robert Granlund
Last Modified: 2015-10-31
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
Watch Question
IT Consultant
This problem has been solved!
Unlock 1 Answer and 3 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE