Connecting Tech Pros Worldwide Help | Site Map

Problem with arrays

 
LinkBack Thread Tools Search this Thread
  #1  
Old June 28th, 2006, 05:25 AM
iblamemicrosoft@gmail.com
Guest
 
Posts: n/a
Default Problem with arrays

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, 06:35 AM
lorento
Guest
 
Posts: n/a
Default 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, 06:45 AM
iblamemicrosoft@gmail.com
Guest
 
Posts: n/a
Default 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, 02:25 PM
Bob Stearns
Guest
 
Posts: n/a
Default 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).
 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,989 network members.