Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    May 2009
    Location
    Bangalore
    Posts
    75
    Thanks
    5
    Thanked 0 Times in 0 Posts

    Question Problem in inserting array in array

    Hi All,

    I have different two dimensional arrays .. I need to insert all these arrays in one array in different indexes .. can any one tell how to do this and how to fetch the array elements..


    Thanx in advance ...

  • #2
    Regular Coder Zangeel's Avatar
    Join Date
    Oct 2007
    Location
    public_html/
    Posts
    638
    Thanks
    17
    Thanked 79 Times in 79 Posts
    Not so sure about what you mean exactly, but his is the basic concept.

    PHP Code:
    $a = array(=> array(=> "Two!"=> "Three!"), => array(=> "Four"));

    echo 
    $a[1][2]; 
    That outputs "Two!" because we're referencing the 1 index point in the first array, then we're referencing the 2, which holds the value of "Two!"
    PHP Code:
    $aString is_string((string)array()) ? true false// true :D 
    [/CENTER]

  • #3
    New Coder
    Join Date
    Aug 2009
    Posts
    17
    Thanks
    4
    Thanked 1 Time in 1 Post
    This is basically the same thing Zangeel said, but written out more verbose:

    PHP Code:
    $a = array();
    $b = array();
    $a[0] = "one";
    $a[1] = "two";
    $b[0] = "uno";
    $b[1] = "dos";

    $c = array();
    $c[0] = $a;
    $c[1] = $b

    print($c[0][0]);  // one
    print($c[0][1]);  // two
    print($c[1][0]);  // uno
    print($c[1][1]);  // dos 


  •  

    Posting Permissions

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