Connecting Tech Pros Worldwide Forums | Help | Site Map

The in_array function works inconsistently

Mountain Man
Guest
 
Posts: n/a
#1: Jul 17 '05
Hi,

The in_array function sometimes malfunctions on my computer yielding
the error message shown below. The code shown below usually works, but
sometimes doesn't. This even happens with the same instance of code.
Different results on different times I load the same page. Can anyone
explain what's going on here?

Best wishes,

Mountain Man
============

Warning: in_array(): Wrong datatype for second argument on line 1.

if (in_array(Yes, $like)) { $like2 = Yes; }
elseif (in_array(No, $like)) { $like2 = No; }

Erwin Moller
Guest
 
Posts: n/a
#2: Jul 17 '05

re: The in_array function works inconsistently


Mountain Man wrote:
[color=blue]
> Hi,
>
> The in_array function sometimes malfunctions on my computer yielding
> the error message shown below. The code shown below usually works, but
> sometimes doesn't. This even happens with the same instance of code.
> Different results on different times I load the same page. Can anyone
> explain what's going on here?
>
> Best wishes,
>
> Mountain Man
> ============
>
> Warning: in_array(): Wrong datatype for second argument on line 1.
>
> if (in_array(Yes, $like)) { $like2 = Yes; }
> elseif (in_array(No, $like)) { $like2 = No; }[/color]

Hi Mountainman,

What excactly is Yes and No?
Didn't you mean a variable $Yes or a string "Yes" ??

Regards,
Erwin Moller
Mountain Man
Guest
 
Posts: n/a
#3: Jul 17 '05

re: The in_array function works inconsistently


> Hi Mountainman,[color=blue]
>
> What excactly is Yes and No?
> Didn't you mean a variable $Yes or a string "Yes" ??
>
> Regards,
> Erwin Moller[/color]

Hi Erwin,

I meant a string "Yes."

Best wishes,

Mountain Man
Closed Thread