473,513 Members | 2,677 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

Jun 28 '07 #1
4 19229
On Jun 28, 5:21 pm, "laredotorn...@zipmail.com"
<laredotorn...@zipmail.comwrote:
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()

Jun 28 '07 #2
Rik
On Thu, 28 Jun 2007 18:50:36 +0200, shimmyshack <ma********@gmail.com>
wrote:
On Jun 28, 5:21 pm, "laredotorn...@zipmail.com"
<laredotorn...@zipmail.comwrote:
>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
Jun 28 '07 #3
On Jun 28, 6:15 pm, Rik <luiheidsgoe...@hotmail.comwrote:
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.comwrote:
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

Jun 28 '07 #4
Rik
On Thu, 28 Jun 2007 19:19:06 +0200, shimmyshack <ma********@gmail.com>
wrote:
On Jun 28, 6:15 pm, Rik <luiheidsgoe...@hotmail.comwrote:
>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.comwrote:
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
Jun 28 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

32
32964
by: Nuno Paquete | last post by:
Hi group. I'm using this code to see if is there any parameter for variable "menu": if($_GET == "downloads") .... But this code log errors if there is no parameter passed (this heappens at the first time the page is loaded). I tryed this code:
7
5183
by: Stefan Richter | last post by:
Hi, I am looking for a good function to check if a entered value is a money value - meaning it's a decimal with no more then 2 digits after the point. Thanks, Stefan
2
3681
by: Dave | last post by:
Can I determine if an array of image links is already in memory without using cookies or a hidden frameset? Scenario: visitor starts with Home page, images (links) for navigation pre-load no problem. Visitor follows search engine link and does not land on Home, thus no links. But if I put the same code on every page to allow for that, won't...
15
2099
by: tabonni | last post by:
I want to check each button groups and save the checked value into a 2 dimensional array. But, it doesn't work. Could anyone tell me what's wrong with my code. My code is as follow: <html> <body> <script language="javascript"> <!-- var temp = new Array(2) var status = new Array();
26
9567
by: JGH | last post by:
How can I check if a key is defined in an associative array? var users = new array(); users = "Joe Blow"; users = "John Doe"; users = "Jane Doe"; function isUser (userID) { if (?????)
8
10152
by: Antony | last post by:
compiler£ºVisual Studio.Net 2003 (VC7.1) compile type£ºDebug problem: wanted more information about the "Run-Time Check Failure #n",thanks! Example1: #include "stdafx.h" void malice() { printf("Hey,you're been attacked.\n");
5
2805
by: wesley | last post by:
Hi all I have many check boxes on a page (The number is unknown) I want to send the results to another page. I will have to name the checkboxes using an array because i dont know how many check boxes there will be. I decided to make the array a $_SESSION variable, but the results are not going to the next page... any suggestions? Thanks Wes
2
1727
by: cpptutor2000 | last post by:
Could some PHP guru please help me? I have very standard PHP - MySQL application that reads in some data from a table and for each row, puts a check box at the start of the row. Now the check boxes are variable in number, depending only on the number of current records in the database table. My question is: how do I count the number of check...
2
2517
by: JasonC | last post by:
Hi, First time posting here so please be gentle! I wish to check a variable for a number of words that are in a array. Not sure if this is the best way to do it, but this is what i have. I have my own counter system that counts every visitor, but some of these visits are from BOTS, spiders..
7
7074
by: yhlove | last post by:
Hi I declared an array as follows: dim a as integer() somewhere else in my program I have the following command: redim preserve a(size) I want to check the array length like that if a.length 1 then
0
7177
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7394
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7559
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7123
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
5701
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
4756
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3248
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
811
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
470
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.