+ Reply to Thread
Results 1 to 2 of 2

Thread: Multidimensional Arrays

  1. #1
    Junior Member
    Join Date
    Feb 2012
    Posts
    3

    Multidimensional Arrays

    I am trying to create a multidimensional array using this code :
    Code:
    $x = "Jack"
    $arr = @()
    
    $arr[$x]["CAR"]["MAKE"] = "BMW"
    But it is not working , any ideas why ?
    Last edited by subboy; 02-23-2012 at 01:09 PM.

  2. #2
    Junior Member
    Join Date
    Feb 2012
    Posts
    4
    You are trying to create an associative array ( hash). Try out the following sequence of commands:
    Code:
    $arr=@{}
    $arr["Jack"] = @{}
    $arr["Jack"]["CAR"] = @{}    
    $arr["Jack"]["CAR"]["MAKE"] ="BMW"
    $arr.jack.car.make
    Note the difference between hashes and arrays
    Code:
    $a = @{} #hash
    $a = @() #array

+ Reply to Thread

Tags for this Thread

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