TalkPHP

TalkPHP (http://www.talkphp.com/forums.php)
-   General (http://www.talkphp.com/general/)
-   -   Array Match String (http://www.talkphp.com/general/3544-array-match-string.html)

buildakicker 10-29-2008 05:06 PM

Array Match String
 
Hi all,

I was wondering why this doesn't work?

Code:

<?php
$todayis = date('F jS Y');

$hday = array("October 28th 2008", "November 11th 2008", "November 27th 2008", "December 25th 2008", "January 1st 2009", "January 19th 2009", "February 16th 2009", "May 25th 2009", "July 3rd 2009", "September 7th 2009", "October 12th 2009", "November 11th 2009", "November 26th 2009", "December 25th 2009");

if (in_array($todayis,$hday))
  {
  echo "Match found";
  }
else
  {
  echo "Match not found";
  }
?>

Can I not use a Variable($todayis), but have to use a string?

Salathe 10-29-2008 05:31 PM

You can use a variable, that's not a problem at all. Remember that the date uses the timezone settings of the server (by default) and for many people it's the 29th (or 30th!) now so we'd expect "Match not found".

buildakicker 10-29-2008 05:34 PM

Thanks for clarifying that... I did have the wrong day in there, so how would it find it?! Got it.


All times are GMT. The time now is 05:36 AM.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0