Page 1 of 1

How to use two diamensional arrays in PHP?

Posted: Fri Jun 23, 2006 7:58 am
by greeshma
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?

Posted: Fri Jun 23, 2006 8:53 am
by bmcewan
Can you show us what your expected table layout should be and also the structure of the data returned from your db query.

Posted: Fri Jun 23, 2006 5:01 pm
by RobertGonzalez
Show us your current array structure.

Posted: Fri Jun 23, 2006 5:13 pm
by Christopher
You can use array() to assign multi-dimensional arrays. Here is an associative array's example:

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",
                 ),
             ),
    );
Ulitmately you need to play with it a little and try different combinations.