how to check if variable is an array?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • laredotornado@zipmail.com

    how to check if variable is an array?

    Hi,

    I'm using php 4.4.4. How do i check if a given variable is an array
    or simply a scalar?

    Thanks, - Dave

  • shimmyshack

    #2
    Re: how to check if variable is an array?

    On Jun 28, 5:21 pm, "laredotorn...@ zipmail.com"
    <laredotorn...@ zipmail.comwrot e:
    Hi,
    >
    I'm using php 4.4.4. How do i check if a given variable is an array
    or simply a scalar?
    >
    Thanks, - Dave
    is_array ?

    there are others:
    is_float()
    is_int()
    is_string()
    is_object()

    Comment

    • Rik

      #3
      Re: how to check if variable is an array?

      On Thu, 28 Jun 2007 18:50:36 +0200, shimmyshack <matt.farey@gma il.com>
      wrote:
      On Jun 28, 5:21 pm, "laredotorn...@ zipmail.com"
      <laredotorn...@ zipmail.comwrot e:
      >Hi,
      >>
      >I'm using php 4.4.4. How do i check if a given variable is an array
      >or simply a scalar?
      >>
      >Thanks, - Dave
      >
      is_array ?
      >
      there are others:
      is_float()
      is_int()
      is_string()
      is_object()
      >
      And don;t forget: is_scalar()


      --
      Rik Wasmus

      Comment

      • shimmyshack

        #4
        Re: how to check if variable is an array?

        On Jun 28, 6:15 pm, Rik <luiheidsgoe... @hotmail.comwro te:
        On Thu, 28 Jun 2007 18:50:36 +0200, shimmyshack <matt.fa...@gma il.com>
        wrote:
        >
        >
        >
        On Jun 28, 5:21 pm, "laredotorn...@ zipmail.com"
        <laredotorn...@ zipmail.comwrot e:
        Hi,
        >
        I'm using php 4.4.4. How do i check if a given variable is an array
        or simply a scalar?
        >
        Thanks, - Dave
        >
        is_array ?
        >
        there are others:
        is_float()
        is_int()
        is_string()
        is_object()
        >
        And don;t forget: is_scalar()
        >
        --
        Rik Wasmus
        yeah theres loads of is_
        theres another one
        is_a_pain_to_re member_them_all
        but it always returns true for me

        Comment

        • Rik

          #5
          Re: how to check if variable is an array?

          On Thu, 28 Jun 2007 19:19:06 +0200, shimmyshack <matt.farey@gma il.com>
          wrote:
          On Jun 28, 6:15 pm, Rik <luiheidsgoe... @hotmail.comwro te:
          >On Thu, 28 Jun 2007 18:50:36 +0200, shimmyshack <matt.fa...@gma il.com>
          >wrote:
          >>
          >>
          >>
          On Jun 28, 5:21 pm, "laredotorn...@ zipmail.com"
          <laredotorn...@ zipmail.comwrot e:
          >Hi,
          >>
          >I'm using php 4.4.4. How do i check if a given variable is an array
          >or simply a scalar?
          >>
          >Thanks, - Dave
          >>
          is_array ?
          >>
          there are others:
          is_float()
          is_int()
          is_string()
          is_object()
          >>
          >And don;t forget: is_scalar()
          >>
          yeah theres loads of is_
          theres another one
          is_a_pain_to_re member_them_all
          but it always returns true for me
          >
          In your standard function library yeah? ;)

          Just pointed it out, as it's normally no problem in PHP to juggle types as
          one goes, but the difference between scalar & non-scalar is often
          significant for functions, so a simple test is_scalar() offcourse beats
          (!is_array()&&! is_object()&&!i s_resource()) or (is_string()||i s_float()).

          --
          Rik Wasmus

          Comment

          Working...