By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
432,035 Members | 1,555 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 432,035 IT Pros & Developers. It's quick & easy.

Problem with arrays

P: n/a
What I'm trying to do is check if the dates in the array $holi[]
matches $evalday (not in an array)
but with limited success the data in the array is:

$holi[1] = 2006-06-20;
$holi[2] = 2006-06-28;
$holi[3] = 2006-07-19;
$holi[4] = 2008-06-24;
$holi[5] = 2006-06-30;

$evalday = date("Y-m-d", strtotime("+ 1 days");

if($evalday == $holi) {
echo("For the purpose of this excercise, $evalday is a holiday");
}

Thanks in advance.

Jun 28 '06 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Try array_search() function:

if (array_search($evalday, $holly))
echo("For the purpose of this excercise, $evalday is a holiday");
--
http://blog.deshot.com
http://www.sederet.com

ib*************@gmail.com wrote:
What I'm trying to do is check if the dates in the array $holi[]
matches $evalday (not in an array)
but with limited success the data in the array is:

$holi[1] = 2006-06-20;
$holi[2] = 2006-06-28;
$holi[3] = 2006-07-19;
$holi[4] = 2008-06-24;
$holi[5] = 2006-06-30;

$evalday = date("Y-m-d", strtotime("+ 1 days");

if($evalday == $holi) {
echo("For the purpose of this excercise, $evalday is a holiday");
}

Thanks in advance.


Jun 28 '06 #2

P: n/a
Thank you, in_array($evalday, $holi) worked. I should have done this
database instead for my school project.

Jun 28 '06 #3

P: n/a
ib*************@gmail.com wrote:
What I'm trying to do is check if the dates in the array $holi[]
matches $evalday (not in an array)
but with limited success the data in the array is:

$holi[1] = 2006-06-20;
$holi[2] = 2006-06-28;
$holi[3] = 2006-07-19;
$holi[4] = 2008-06-24;
$holi[5] = 2006-06-30;

$evalday = date("Y-m-d", strtotime("+ 1 days");

if($evalday == $holi) {
echo("For the purpose of this excercise, $evalday is a holiday");
}

Thanks in advance.

You either have to test each element separately [foreach()
if($holiday = $evalday)...] or use the builtin function
inarray($evalday, $holi).
Jun 28 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.