|
-
Oct 14th, 2007, 12:48 AM
#1
Thread Starter
Lively Member
array variable
sir
i am a newbie in php. how can i put this array in for loop to generate numbers 1, 2, 3, 4.
now i want to declare like this. but if i have 100 numbers it is very diffcult. please tell me
how can i use variable in the place of 1, 2, 3, 4, 5?
$days = array(
1=>array('testing','linked-day'),
2=>array('testing','linked-day'),
3=>array('testing','linked-day'),
4=>array('testing','linked-day'),
5=>array('testing','linked-day'),
);
ram
-
Oct 14th, 2007, 09:52 AM
#2
Re: array variable
If you omit the key when creating an array then the default zero-based numerical indices are used.
PHP Code:
$days = array(
array('testing', 'linked-day'),
array('testing', 'linked-day'),
array('testing', 'linked-day'),
array('testing', 'linked-day')
# etc.
);
1-based arrays are unnecessarily confusing. Either zero-based numerical indices or alphanumeric keys should be used (as a matter of fact, if you specify a string key for each item, you can still access them using zero-based indices).
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|