# Function Reference

# _ArrayToString

Places the elements of a 1D or 2D array into a single string, separated by the specified delimiters

#include <Array.au3>
_ArrayToString ( Const ByRef $aArray [, $sDelim_Col = "|" [, $iStart_Row = Default [, $iEnd_Row = Default [, $sDelim_Row = @CRLF [, $iStart_Col = Default [, $iEnd_Col = Default]]]]]] )

## Parameters

$aArray | Array to convert to a string
$sDelim_Col | [optional] Delimiter for elements of 1D array or columns of 2D array
$iStart_Row | [optional] Index of array row to start copy (Default = 0)
$iEnd_Row | [optional] Index of array row to stop copy (Default = number of Rows)
$sDelim_Row | [optional] Delimiter for rows of 2D array (2D only)
$iStart_Col | [optional] Index of array column to start copy (2D only) (Default = 0)
$iEnd_Col | [optional] Index of array column to stop copy (2D only) (Default = Number of Columns)

## Return Value

Success: | a string which combined selected elements separated by the delimiters.
Failure: | sets the @error flag to non-zero.
@error: | 1 - $aArray is not an array 2 - $aArray is not a 1D or 2D array 3 - $iStart_Row or $iEnd_Row outside array bounds 4 - $iStart_Row greater then $iEnd_Row 5 - $iStart_Col or $iEnd_Col outside array bounds 6 - $iStart_Col greater then $iEnd_Col

## Remarks

Note that if the passed array has one of the following formats and no content - [0], [1], [0][0], [1][0], [0][1], [1][1] - this function returns an empty string. If this string is subsequently passed to _ArrayFromString(), that function cannot distinguish between these cases and will default to a single element array with no content: either [1] or [1][1] depending on the $bForce2D flag.

## Related

_ArrayFromString, _ArrayToClip

## Example

    #include <Array.au3>
    #include <MsgBoxConstants.au3>

    Local $aArray[20]
    For $i = 0 To 19
        $aArray[$i] = $i
    Next
    _ArrayDisplay($aArray, "1D Array")
    MsgBox($MB_SYSTEMMODAL, "Items 1-7", _ArrayToString($aArray, @TAB, 1, 7))

    Local $aArray[10][10]
    For $i = 0 To 9
        For $j = 0 To 9
            $aArray[$i][$j] = $i & "-" & $j
        Next
    Next
    _ArrayDisplay($aArray, "2D Array")
    MsgBox($MB_SYSTEMMODAL, "Rows 4-7,  cols 2-5", _ArrayToString($aArray, " :: ", 4, 7, @CRLF, 2, 5))