I have a list of courses like PHP,C++..etc. and each courses consists a number of modules.For example the PHP course contains modules are 1.introduction
2.basics
3.syntax etc..
I want to display each course and its correspoding modules using a for loop.
I have all this details in an array from the database and i want to store it some other arrayand display the details in a table.How can i do it?
How to use two diamensional arrays in PHP?
Moderator: General Moderators
- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA
- Christopher
- Site Administrator
- Posts: 13596
- Joined: Wed Aug 25, 2004 7:54 pm
- Location: New York, NY, US
You can use array() to assign multi-dimensional arrays. Here is an associative array's example:
Ulitmately you need to play with it a little and try different combinations.
Code: Select all
$var = array(
'key1' => "this is a string value",
'key2' => $the_value_in_this_var_will_be_used,
'key3' => array(
'key3-key1' => "this is a string value",
'key3-key2' => array(
'key3-key2-key1' => "this is a string value",
'key3-key2-key2' => "this is another string value",
),
),
);(#10850)