|
Re: output multiple arrays to file It occurred to me that there must be a simple way to combine two
arrays.
But I couldn't think of it, so wrote this very simple function that
might be of use to
someone, somewhere, someday.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
function combine-arrays ( $array1,$array2 ) {
if ($array1.count -ne $array2.count) { "Arrays are different sizes" ;
exit }
$newarray = @()
$c = $array1.count
for ( $i = 0; $i -le $c; $i++ ) {
$newarray += $array1[$i]
$newarray += $array2[$i]
}
return $newarray
}
$a = 1..10
$b = 11..20
combine-arrays $a $b
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Hope it helps,
Stuart |