The in_array function works inconsistently

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Mountain Man

    The in_array function works inconsistently

    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

    #2
    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

    Comment

    • Mountain Man

      #3
      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

      Comment

      Working...