Quick Array help question

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
toppac
Forum Commoner
Posts: 29
Joined: Fri Jun 14, 2002 10:44 am

Quick Array help question

Post by toppac »

This a dumb question but I am really tired and not thinking straight. How do I make a 2 dimensional array, where the columns are referenced by name and the rows are referenced by number. something like

Name--Date--Age--City
1
2
3

I cant remember how to do it. Maybe after lunch I will :wink:
User avatar
llimllib
Moderator
Posts: 466
Joined: Mon Jul 01, 2002 2:19 pm
Location: Baltimore, MD

Post by llimllib »

You don't need to use nested array() statements (though you could). The easiest way is just to initialize the elements as you want:

Code: Select all

$arrayї1]ї'name'] = 'John';
$arrayї1]ї'date'] = '9.19.82';
$arrayї1]ї'city'] = 'Dublin';
$arrayї2]ї'name'] = 'Steve';
$arrayї2]ї'date'] = '10.12.92';
and so on
Post Reply