Connecting Tech Pros Worldwide Help | Site Map

Problem with arrays

  #1  
Old June 28th, 2006, 06:25 AM
iblamemicrosoft@gmail.com
Guest
 
Posts: 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.

  #2  
Old June 28th, 2006, 07:35 AM
lorento
Guest
 
Posts: n/a

re: Problem with arrays


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

iblamemicrosoft@gmail.com wrote:[color=blue]
> 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.[/color]

  #3  
Old June 28th, 2006, 07:45 AM
iblamemicrosoft@gmail.com
Guest
 
Posts: n/a

re: Problem with arrays


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

  #4  
Old June 28th, 2006, 03:25 PM
Bob Stearns
Guest
 
Posts: n/a

re: Problem with arrays


iblamemicrosoft@gmail.com wrote:
[color=blue]
> 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.
>[/color]
You either have to test each element separately [foreach()
if($holiday = $evalday)...] or use the builtin function
inarray($evalday, $holi).
Closed Thread


Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem with arrays (I think) Cainnech answers 10 January 7th, 2008 12:25 PM
Problem With Arrays Of Arrays, PHP 5.2.0, Windows Jim Carlock answers 0 January 29th, 2007 01:15 PM
memory leak problem with arrays sonjaa answers 13 June 20th, 2006 05:45 PM
A problem with arrays elmoizwaly@mobifree.net answers 2 January 28th, 2006 08:05 AM
Problem with arrays Xarky answers 2 November 16th, 2005 02:46 PM