in_array() question

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • paul brown

    in_array() question

    hello,

    I have this code sample:

    class Sexboard extends Master
    {
    var $userid;
    var $errormessage;
    var $dc_metro = array(20, 46, 51);

    ....

    function get_select_by_u ser_online_sql( $stateid, $cityid)
    {
    ...

    if( in_array( $stateid, $this->$dc_metro ) )
    {
    ...
    }

    }



    }

    My question is why do I get a warning message saying the wrong data type
    for the second parameter?

    Thanks,

    Paul

  • Garp

    #2
    Re: in_array() question


    "paul brown" <paul@paulbrown .net> wrote in message
    news:1nWLc.602$ AY5.260@newssvr 21.news.prodigy .com...[color=blue]
    > hello,[/color]
    <snip>[color=blue]
    > if( in_array( $stateid, $this->$dc_metro ) )
    >
    > My question is why do I get a warning message saying the wrong data type
    > for the second parameter?[/color]


    Lose the second dollar when using object's members (and read the docs for
    why):
    if( in_array( $stateid, $this->dc_metro ) )

    HTH
    Garp


    Comment

    • paul brown

      #3
      Re: in_array() question

      paul brown wrote:
      [color=blue]
      > hello,
      >
      > I have this code sample:
      >
      > class Sexboard extends Master
      > {
      > var $userid;
      > var $errormessage;
      > var $dc_metro = array(20, 46, 51);
      >
      > ...
      >
      > function get_select_by_u ser_online_sql( $stateid, $cityid)
      > {
      > ...
      >
      > if( in_array( $stateid, $this->$dc_metro ) )
      > {
      > ...
      > }
      >
      > }
      >
      >
      >
      > }
      >
      > My question is why do I get a warning message saying the wrong data type
      > for the second parameter?
      >
      > Thanks,
      >
      > Paul[/color]

      OK, I figured it out on my own... That dollar_sign before the dc_metro
      was not needed... hooray for documentation!

      Paul

      Comment

      • paul brown

        #4
        Re: in_array() question

        Garp wrote:
        [color=blue]
        > "paul brown" <paul@paulbrown .net> wrote in message
        > news:1nWLc.602$ AY5.260@newssvr 21.news.prodigy .com...
        >[color=green]
        >>hello,[/color]
        >
        > <snip>
        >[color=green]
        >>if( in_array( $stateid, $this->$dc_metro ) )
        >>
        >>My question is why do I get a warning message saying the wrong data type
        >>for the second parameter?[/color]
        >
        >
        >
        > Lose the second dollar when using object's members (and read the docs for
        > why):
        > if( in_array( $stateid, $this->dc_metro ) )
        >
        > HTH
        > Garp
        >
        >[/color]

        Hi, and yes this would have helped, had I not found the answer in the docs.

        Thanks, though, for your response,

        Paul

        Comment

        • Garp

          #5
          Re: in_array() question


          "paul brown" <nntp@paulbrown .net> wrote in message
          news:ONWLc.610$ AY5.229@newssvr 21.news.prodigy .com...[color=blue]
          > Garp wrote:
          >[color=green]
          > > "paul brown" <paul@paulbrown .net> wrote in message
          > > news:1nWLc.602$ AY5.260@newssvr 21.news.prodigy .com...
          > >[color=darkred]
          > >>hello,[/color]
          > >
          > > <snip>
          > >[color=darkred]
          > >>if( in_array( $stateid, $this->$dc_metro ) )
          > >>
          > >>My question is why do I get a warning message saying the wrong data type
          > >>for the second parameter?[/color]
          > >
          > >
          > >
          > > Lose the second dollar when using object's members (and read the docs[/color][/color]
          for[color=blue][color=green]
          > > why):
          > > if( in_array( $stateid, $this->dc_metro ) )
          > >
          > > HTH
          > > Garp
          > >
          > >[/color]
          >
          > Hi, and yes this would have helped, had I not found the answer in the[/color]
          docs.[color=blue]
          >
          > Thanks, though, for your response,
          >
          > Paul
          >[/color]

          I'm still claiming credit. 8P

          Garp


          Comment

          Working...