Associative Array...Help Please..

Discussion in 'PHP' started by daimous, Jan 22, 2006.

  1. #1
    Can anybody pls. help me..here's my problem..I have this array
    $name = array("daimous","Art","John","Mike") and i want to make that array into associative array thus i want to associate the age,gender into its name.
    any inputs will be greatly appreciated.
     
    daimous, Jan 22, 2006 IP
  2. rossriley

    rossriley Guest

    Messages:
    25
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    0
    #2
    $name = array(
       "daimous"=>array("age"=>'30', "gender"=>'M'),
       "Art"=>array("age"=>'40', "gender"=>'M'),
       "John"=>array("age"=>'50', "gender"=>'M'),
       "Mike"=>array("age"=>'60', "gender"=>'M')
    )
    Code (markup):
    is one way of doing it....
    then you do echo $name['Mike']['age']; to get a value.

    Ross
     
    rossriley, Jan 22, 2006 IP
    sarahk likes this.