I have 2 dimension array. I would like to get each value of array. I tried this, but each array in $Name has all the array in $Date. But my expectation first item in $Name equal to first item in $Date. This is my expectation result:
A\11
B\12
C\13
$Name = @("A", "B", "C") #the size of this array not fixed
$Date = @("11", "12", "13") #the size of this array not fixed
foreach ($na in $Name)
{
foreach ($dt in $Date)
{
$NameAndDate = "$na\$dt"
Write-Host $NameAndDate
}
}
but from the code above I got this result
A\11
A\12
A\13
B\11
B\12
B\13
C\11
C\12
C\13
Anyone can help, please. Thank you
For ($i = 0; $i -lt $name.count; $i++){ ($Name[$i]) + "\" + ($Date[$i]) }A\11 B\12 C\13what I would guess you would actually expect (and what is described in the duplicate). But in your example script, you haveA\11 B\12 B\13 C\13in top, is that what you expect as an output? If yes, please explain where where theB\13is coming from.