Login or Sign Up
Logging in...
Remember me
Log in
Or
Sign Up
Forgot password or user name?
Log in with
Search in titles only
Search in PHP only
Search
Advanced Search
Forums
BYTES
Product Launch
Updates
Developer Toolkit
Today's Posts
Member List
Calendar
Home
Forum
Topic
PHP
Declaring array in php
Collapse
X
Collapse
Posts
Latest Activity
Photos
Page
of
1
Filter
Time
All Time
Today
Last Week
Last Month
Show
All
Discussions only
Photos only
Videos only
Links only
Polls only
Events only
Filtered by:
Clear All
new posts
Previous
template
Next
x1y1z1
New Member
Join Date:
May 2007
Posts:
1
#1
Declaring array in php
May 29 '07, 06:08 PM
hi
how to declare this c array(eg:int var[10]))in php.
pbmods
Recognized Expert
Expert
Join Date:
Apr 2007
Posts:
5821
#2
May 29 '07, 06:14 PM
Heya, x1y1z1. Welcome to TSDN!
Originally posted by
x1y1z1
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:
[code=php]
$myVar = 5;
$myVar = 'Hi!';
[/code]
Having said that, to declare an array in PHP, you'd just use the array keyword:
[code=php]
$myVar = array(
'key' => 'value'
);
[/code]
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:
PHP: Variables - Manual
http://php.net/variables
Variables
Comment
Post
Cancel
Previous
template
Next
Working...
Yes
No
OK
OK
Cancel
👍
👎
☕
Comment