[SOLVED] foreach help

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
irishmike2004
Forum Contributor
Posts: 119
Joined: Mon Nov 15, 2004 3:54 pm
Location: Lawrence, Kansas

[SOLVED] foreach help

Post 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!
User avatar
markl999
DevNet Resident
Posts: 1972
Joined: Thu Oct 16, 2003 5:49 pm
Location: Manchester (UK)

Post by markl999 »

Maybe use in_array.
irishmike2004
Forum Contributor
Posts: 119
Joined: Mon Nov 15, 2004 3:54 pm
Location: Lawrence, Kansas

That did it

Post by irishmike2004 »

Hi the in_array() function does the trick. This is solved. Thanks.
Post Reply