Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can this be done...

Status
Not open for further replies.

GavW

Programmer
Jan 13, 2006
58
GB
Hey all!

I would just like to know if the following is possible. I think it is im just not sure how to code it.

Instead of saying:

(IF array[0] == 1 || array[1] == 1 || array[2] == 1)

Can i reduce this to specify that i want to check through my array? So for example:

(IF array[0-2] == 1)

Assuming this is possible i then need to count all the occasions when one of my array values is equal to 1.

Thanks in advance

GavW
 
How about:
Code:
$onecount = 0;
for ($arrindex=0;$arrindex < count($array);$arrindex++)
  {
  if ($array[$arrindex] == 1) $onecount++;
  }
if ($onecount > 0)
  {
  //whatever code you want here
  }


Not quite what you had in mind, but it does what you want.

Lee
 
Cheers mate, works perfectly for what I want it to do!

Thanks again.

GavW
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top