473,587 Members | 2,447 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 19236
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()

Jun 28 '07 #2
Rik
On Thu, 28 Jun 2007 18:50:36 +0200, shimmyshack <ma********@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
Jun 28 '07 #3
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

Jun 28 '07 #4
Rik
On Thu, 28 Jun 2007 19:19:06 +0200, shimmyshack <ma********@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
Jun 28 '07 #5

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

Similar topics

32
33002
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
5189
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
3689
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 the images re-load every time those pages are loaded? If so, there's be no point in pre-loading. ...
15
2111
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
9598
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
10155
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
2811
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
1731
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 boxes rendered at any one time. I tried having a global variable and incrementing it each time a...
2
2525
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
7084
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
7924
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
7854
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
7978
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 most users, this new feature is actually very convenient. If you want to control the update process,...
0
6629
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 launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
3845
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
3882
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2364
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1455
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1192
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.