This is a discussion on The in_array function works inconsistently within the alt.comp.lang.php forums, part of the PHP Programming Forums category; Hi, The in_array function sometimes malfunctions on my computer yielding the error message shown below. The code shown below usually ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
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; } |
|
|||
|
Mountain Man wrote:
> 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; } Hi Mountainman, What excactly is Yes and No? Didn't you mean a variable $Yes or a string "Yes" ?? Regards, Erwin Moller |