By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
432,109 Members | 969 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 432,109 IT Pros & Developers. It's quick & easy.

Declaring array in php

P: 1
hi
how to declare this c array(eg:int var[10]))in php.
May 29 '07 #1
Share this Question
Share on Google+
1 Reply


pbmods
Expert 5K+
P: 5,821
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

Post your reply

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