storing into multi dimensional array

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sbettadpur
    New Member
    • Aug 2007
    • 121

    storing into multi dimensional array

    Hello,

    I am getting resulted data from the mysql table like this.......

    Code:
    CATEGORY            SUB-CATEGORY
                         
    Books                       ----
    Business                   ----
    Education                 -----
    Games                      Family
    Games                      Puzzle
    Games                      Racing
    Healthcare                 ----------
    Lifestyle                    ----------
    I want to store these values in a multi dimension array

    Example
    If I print like this $array['Games'][0] this should print values as "Family";
    Similarly
    If I print $array['Games'][1] it should print values as "Puzzle";

    I am getting above result from the query by doing join multiple tables.

    Pls let me know if anyone have idea about this.

    Thank you
  • Atli
    Recognized Expert Expert
    • Nov 2006
    • 5062

    #2
    Hey.

    You could do this with a simple while loop, iterating through the MySQL result resource, adding elements to your $array by using the 'CATEGORY' as the key and the 'SUB-CATEGORY' as the value of the new element.

    Comment

    Working...