Skip to content

Instantly share code, notes, and snippets.

@ecspresso
Created February 17, 2020 14:38
Show Gist options
  • Save ecspresso/f5140c7e372f43093047d0f9695ac778 to your computer and use it in GitHub Desktop.
Save ecspresso/f5140c7e372f43093047d0f9695ac778 to your computer and use it in GitHub Desktop.
function Join-Array {
param (
[int]$ItemsPerLine,
[string]$separator,
[string[]]$array
)
for($i = 0; $i -lt $array.length; $i = $i + $ItemsPerLine) {
$array[$i..($i + $ItemsPerLine)] -join $separator
}
}
# my test array
$items = (100..117) | ForEach-Object {"Item-$_"}
# join it up
Join-Array 5 '; ' $items
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment