Array datatype warning

Here’s the warning:

Warning: in_array() []: Wrong datatype for second argument in /home/whatsonn/public_html/includes/ on line 123

Here’s the line in question:

if(in_array(date("d/m/Y", $timestamp),$startDates))

And that’s all I know. Is $timestamp or $startDates the second argument, and what datatype should it be?

The first argument is the result of the function call to date, and the second is $startDates

function(argument 1, argument 2)

if(in_array(date(“d/m/Y”, $timestamp),$startDates))

It should be an array but isn’t

you’re using an array function. what type do you think it’s argument should be? an integer? :slight_smile:

It seems $startDates should be defined before but failed.

Thanks Dan.

change to

if(in_array(date("d/m/Y", $timestamp), array($startDates)) )

array() is not a typecasting function, so if $startDates is sometimes an array like it’s supposed to be, this will encapsulate that array in another and the function won’t work.

yes array is not a typecasting function. but we can make element an part of an array using like:

$startDate = '2010-01-14';
echo $startDate; //just a string
$new_array = array($startDate); //becomes an part of the array