Page 1 of 1

[SOLVED] foreach help

Posted: Wed Jan 12, 2005 7:52 pm
by irishmike2004
I am working in a subsection of a big project and basically there is an array of holiday dates. There are 11, elements 0-10.

What I need to accomplish is checking each member in the array against today... for example:

Code: Select all

if($today == $holiday_arrayї$i])
{
     flag = 1;
}
else
{
     flag = 0;
}
Or if someone has a better idea of how to do this, basically I am trying to make sure that today is not a holiday (based on the array) and then if one matches today then set a flag to on so that we can say fail for the function.

Thanks for your help!

Posted: Wed Jan 12, 2005 7:53 pm
by markl999
Maybe use in_array.

That did it

Posted: Wed Jan 12, 2005 8:35 pm
by irishmike2004
Hi the in_array() function does the trick. This is solved. Thanks.