473,394 Members | 1,797 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Declaring array in php

1
hi
how to declare this c array(eg:int var[10]))in php.
May 29 '07 #1
1 13421
pbmods
5,821 Expert 4TB
Heya, x1y1z1. Welcome to TSDN!

how to declare this c array(eg:int var[10]))in php.
Hm. Where to begin on this one?

PHP variables are significantly different from C variables. C variables are statically-typed (e.g., int myVar can only hold int values, etc.).

On the other hand, PHP values are dynamically-typed. So you could do this without causing any problems:
Expand|Select|Wrap|Line Numbers
  1. $myVar = 5;
  2. $myVar = 'Hi!';
  3.  
Having said that, to declare an array in PHP, you'd just use the array keyword:

Expand|Select|Wrap|Line Numbers
  1. $myVar = array(
  2.     'key' => 'value'
  3. );
  4.  
The array can have as many or as few elements as you want. You don't have to specify this when you create the array.

For more information, check out the PHP Manual:
http://php.net/variables
May 29 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

29
by: Friday | last post by:
Sorry if this is the wrong group. I tried to find the one I thought would be most relevant. I'm an old PHP guy, who knows little about asp and NOTHING about asp.net, but need to learn at least...
5
by: ms_chika | last post by:
Hi to all, I have this problem in declaring a two-dimesional array, how will i declare such array with unknown number of rows? Your help will be very much appreciated. Thanks in advance. ...
18
by: Nathan | last post by:
If you're wondering why I post so many questions, it's because I want to make an entry in the Guinness Book of World Records. But because I post so many, I try to make them simple. Here is (I...
3
by: mark | last post by:
When I declare an array as double(,) then try to use it I get an error: "Object reference not set to an instance of an object." I have found that I can redim the array and all is well. Is my...
1
by: John Dann | last post by:
Is there a way of declaring an array of a structure where the structure has a constructor? So if I had a structure say Friend MyStructure prop1 as integer prop2 as string sub New (p1 as...
3
by: hn.ft.pris | last post by:
I've got following code test C++'s functor. For the sake of easy-reading, I omit some declearations. #include <algorithm> #include <functional> using namespace std;
16
by: dejavu33 | last post by:
Hi! I dont understand arrays very much. Im trying to create an array of up to 100 positive numbers with the use of -1 to stop entering if the user needs an array containing less than 100...
5
by: =?Utf-8?B?RWl0YW4=?= | last post by:
Hello, I am declaring an element like this: public static List<myListElementmyList = new List<myListElement>(); I would like to declare an array of this myList. How would I modify the...
4
by: Peter Duniho | last post by:
On Thu, 14 Aug 2008 18:56:00 -0700, Phill <Phill@discussions.microsoft.comwrote: For future reference, if you are asking for help with an error (compile or execution), you really should post...
8
by: bintom | last post by:
What are the differences between the following methods of declaring strings? char string1 = "C++ forum"; char* string2 = "C++ forum"; I know that the first uses the array notation, whereas...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
0
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,...
0
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...
0
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.