# array.toStruct()

Transform the array to a struct, the index of the array is the key of the struct

```
array.toStruct( valueAsKey=boolean )
```

**Returns:** struct

# Arguments

| Argument | Type | Required | Description | Default |
|----------|------|----------|-------------|---------|
| valueAsKey | boolean | No | use the value as the key of the struct, rather than the index |  |

# Examples

```1
myarray = ["one","two","three","four","five"];
res = myarray.tostruct();
writeDump(res);
```

# Categories

[Arrays](../../../categories/array.md), [Structures](../../../categories/struct.md)

# See Also

[ArrayToStruct()](../../functions/arraytostruct.md), [Array](../array.md)