how to check if variable is an array?

This is a discussion on how to check if variable is an array? within the PHP Language forums, part of the PHP Programming Forums category; Hi, I'm using php 4.4.4. How do i check if a given variable is an array or ...


Go Back   Usenet Forums > PHP Programming Forums > PHP Language

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 06-28-2007
laredotornado@zipmail.com
 
Posts: n/a
Default 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

Reply With Quote
  #2 (permalink)  
Old 06-28-2007
shimmyshack
 
Posts: n/a
Default Re: how to check if variable is an array?

On Jun 28, 5:21 pm, "laredotorn...@zipmail.com"
<laredotorn...@zipmail.com> wrote:
> 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()

Reply With Quote
  #3 (permalink)  
Old 06-28-2007
Rik
 
Posts: n/a
Default Re: how to check if variable is an array?

On Thu, 28 Jun 2007 18:50:36 +0200, shimmyshack <matt.farey@gmail.com>
wrote:

> On Jun 28, 5:21 pm, "laredotorn...@zipmail.com"
> <laredotorn...@zipmail.com> wrote:
>> 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
Reply With Quote
  #4 (permalink)  
Old 06-28-2007
shimmyshack
 
Posts: n/a
Default Re: how to check if variable is an array?

On Jun 28, 6:15 pm, Rik <luiheidsgoe...@hotmail.com> wrote:
> On Thu, 28 Jun 2007 18:50:36 +0200, shimmyshack <matt.fa...@gmail.com>
> wrote:
>
>
>
> > On Jun 28, 5:21 pm, "laredotorn...@zipmail.com"
> > <laredotorn...@zipmail.com> wrote:
> >> 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_remember_them_all
but it always returns true for me

Reply With Quote
  #5 (permalink)  
Old 06-28-2007
Rik
 
Posts: n/a
Default Re: how to check if variable is an array?

On Thu, 28 Jun 2007 19:19:06 +0200, shimmyshack <matt.farey@gmail.com>
wrote:

> On Jun 28, 6:15 pm, Rik <luiheidsgoe...@hotmail.com> wrote:
>> On Thu, 28 Jun 2007 18:50:36 +0200, shimmyshack <matt.fa...@gmail.com>
>> wrote:
>>
>>
>>
>> > On Jun 28, 5:21 pm, "laredotorn...@zipmail.com"
>> > <laredotorn...@zipmail.com> wrote:
>> >> 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_remember_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()&&!is_resource()) or (is_string()||is_float()).

--
Rik Wasmus
Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT +1. The time now is 06:14 PM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0