I have an array with fields (a multi dimensional array, if I am correct), my aim is to create another array based on elements filtered from the first.
However when I come to deference $arr2 by looking at its first element $arr[0], I get the error message:
Cannot index into a null array
Can someone please provide me with some advise as to the most elegant way of resolving this.
for ($i=0; $i -lt $arr1.length; $i++) {
if ($arr1[$i].source -eq $SomeValue) {
$arr2 += @( $arr1[$i] )
}
}
$arr2anywhere. Trying putting$arr2 = @()at the top of your code.$arr2 += $arr1[$i]?