How to check if a variable is an array?

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

d60eba
New php-forum User
New php-forum User
Posts: 6
Joined: Wed Jul 02, 2003 7:19 am
Location: Barcelona

How to check if a variable is an array?

Postby d60eba » Wed Jul 02, 2003 7:25 am

Hello all,

My first post here, this looks like a great forum you have!

The question:

I have a script which implodes an array to make it into a string variable. However, the only catch is that sometimes this variable isn't an array, and I get nasty implode error messages. I have looked around on the net and in the PHP manual for a function that can tell me whether my variable is an array or not. But I can't find one! I was hoping for something like:

is_array($array);

Does such a function exist? Or if not, how can I make one?

Many thanks in advance!

User avatar
ruturajv
php-forum Super User
php-forum Super User
Posts: 1280
Joined: Sat Mar 22, 2003 9:42 am
Location: Mumbai, India
Contact:

here is the wizard of PHP

Postby ruturajv » Wed Jul 02, 2003 8:00 am

is_array
(PHP 3, PHP 4 >= 4.0.0)

is_array -- Finds whether a variable is an array
Description

bool is_array (mixed var)


Returns TRUE if var is an array, FALSE otherwise.

:lol: :lol:

IT is from the PHP manual

d60eba
New php-forum User
New php-forum User
Posts: 6
Joined: Wed Jul 02, 2003 7:19 am
Location: Barcelona

Postby d60eba » Wed Jul 02, 2003 8:38 am

I don't believe it! I looked all over the manual and the internet and couldn't find it. Thanks ruturajv!


Return to “PHP coding => General”

Who is online

Users browsing this forum: No registered users and 1 guest

cron