"Christopher9" wrote:
I am reading the php manual online and don’t understand the way
arrays work.
It says arrays take a key, value pair which is fine I guess, but
how do I
get an old fashion c style array? Are the keys like the indices?
say I want an array that contains the numbers 0 through 10, what do
I make
the keys or does it even matter?
Thanx,
Chris
Chris, php is easy going, and at the same time, great in managing
arrays. Compared to c, most of the hard work is done for you.
So you can say
$a = array (’x’, ’y’, 33);
then $a[0] = ’x’ and $a[1] = ’y’ and $a[2] = 33
as you see, phy is just incrementing the key as it is assigning. You
can also mix types-as php is very forgiving.
Now to add another item to the array, simply do:
$a[] = 44;
in this case $a[4] = 44
you can also set the keys to be whatever you want, e.g.
$b = array( ’key1’ => 22, ’key2’ => 55);
then $b[’key1’] = 22 ...
Also php will assign incrementing keys - in addition to the defined
keys.
So $b[0] = 22 as well.
--
http://www.dbForumz.com/ This article was posted by author's request
Articles individually checked for conformance to usenet standards
Topic URL:
http://www.dbForumz.com/PHP-arrays-ftopict130390.html
Visit Topic URL to contact author (reg. req'd). Report abuse:
http://www.dbForumz.com/eform.php?p=435003