Empty Array causing an error

I have a large query and part of it depends upon a returned Array.  If there is no data returned by the query, the Array is empty, obviously.  But My code so far has an area that is looking for the the second part of the Array Data:
<?php
$a = false;
  $b = false; 
  if($wave[0] <= $wave_max) $a = true; 
   if($wave[1] >= $wave_min) $b = true; 
   			
   	$wavelength = '';
   				
   	if($a && $b) $wavelength = true;

Open in new window

So if the return is empty, I get an error on this line:  if($wave[1] >= $wave_min) $b = true; , the second part of the array.
The error message is:
A PHP Error was encountered
Severity: Notice
Message: Undefined offset: 1
And refers to that line
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.

Dave BaldwinFixer of ProblemsCommented:
You can use 'isset' to check to see if the variable exists.

I typically use 'isset' check $_POST variables to see if they exist and set them to a default values if they don't.  Something like below.

http://php.net/manual/en/function.isset.php
if(!isset($wave[1])) $wave[1] ='';

Open in new window

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:
Thanks Dave.  I have been spinning my wheels for a while.
Dave BaldwinFixer of ProblemsCommented:
You're welcome, glad to help.
Ray PaseurCommented:
You may find this function useful, too.
http://php.net/manual/en/function.empty.php
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.