SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Evangelist dscriptor's Avatar
    Join Date
    Oct 2005
    Location
    in front of my computer
    Posts
    571
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    put an array inside an an array

    hi all,

    i need help in this situation:

    lets say i have an array like:
    Code:
    Array(
      [method1]
       (
          [id] => 10
          [title] => first
          [cost] => 20
        
       )
    
     [method2]
       (
          [id] => 11
          [title] => second
          [cost] => 50
        
       )
    )
    now i want to put each value of the above method arrays inside this array:
    PHP Code:
     $this->quotes = array('id' => $this->code,
                                
    'module' => TEXT_QUOTE,
                                
    'methods' => array( array(//keys and values of method1 here
                                                     
    ),
                                                  array( 
    // keys and values of method2 here
                                                      
    ));
                                   ) 
    can anyone help me here?

    thanks in advance...
    happy is the man that finds wisdom....wisdom in {PHP}.


  2. #2
    SitePoint Wizard gRoberts's Avatar
    Join Date
    Oct 2004
    Location
    Birtley, UK
    Posts
    2,439
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i'm new to php so there may be an easier way.

    but...

    Code:
    $this->quotes[0]["id"] = $this->code;
    $this->quotes[0]["module"] = TEXT_QUOTE;
    $this->quotes[0]["methods"][0]["method1"] = "method1value";
    $this->quotes[0]["methods"][0]["method2"] = "method2value";



Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •