I'm populating an array variable $array
at some point in my code, for example like below
this
is
an
array
varaible
What if, I wanted to print out the array variable like thisisanarrayvariable
as one liner
i took the below approach, but i'am not getting any out while the program is hanging
for ($i=0;$i -le $array.length; $i++)
{ $array[$i] }
obviuosly, i dont want to glue them together like $array[0]+$array[1]+$array[2]..
Hope i can get a better answer.
Use the -join
operator:
$array -join '';
You can also call the String.Join
method:
[String]::Join('', $array);
In either case the result will be a new String
instance with each element in $array
concatenated together.
Just use
-join $array
which will glue all elements together.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With