---
name: "toArray"
type: command
status: ok
groups: ["Arrays", "HashMap", "Strings"]
arma3_since: "0.50"
locality: {"argument": null, "effect": null, "server_exec": false}
source: https://community.bistudio.com/wiki/toArray
revid: 377121
updated: 2026-01-01T10:18:13Z
---

# toArray

*Command · Arrays, HashMap, Strings · Arma 3 v0.50 · introduced in Armed Assault v1.09*

## Description

Converts the supplied [String](../topics/String.md) into an [Array](../topics/Array.md) of [Number](../topics/Number.md)s. The numbers in the created array are the decimal [Unicode](https://en.wikipedia.org/wiki/Unicode) representations of characters.

> [!NOTE]
> **Arma 3:** Since v2.04 this command can also handle [HashMap](../topics/HashMap.md)s. See alternative syntax.

## Syntax

### Syntax 1

```sqf
toArray string
```

**Parameters:**

- `string`: [String](../topics/String.md)

**Returns:** [Array](../topics/Array.md) of [Number](../topics/Number.md)s

### Syntax 2

*since arma3 2.04*

```sqf
toArray hashMap
```

**Parameters:**

- `hashMap`: [HashMap](../topics/HashMap.md)

**Returns:** [Array](../topics/Array.md) - array in format [[key, key, ...], [value, value, ...]]

### Syntax 3

*since arma3 2.04*

```sqf
hashMap toArray splitArrays
```

**Parameters:**

- `hashMap`: [HashMap](../topics/HashMap.md)
- `splitArrays`: [Boolean](../topics/Boolean.md) - see return value

**Returns:** [Array](../topics/Array.md) - array in either one of the following formats:
- splitArrays: [true](../commands/true.md) - `[[key1, key2, ...], [value1, value2, ...]]`
- splitArrays: [false](../commands/false.md) - `[[key1, value1], [key2, value2], ...]` This is **very inefficient** since the engine has to create many small arrays

## Examples

### Example 1

```sqf
hint format ["%1", toArray "AaŒ"];// Returns "[65,97,338]"
```

### Example 2

```sqf
toArray _hashMap params ["_keys", "_values"];
```

### Example 3

```sqf
private _hashmap = ["cow", "cat", "chicken"] createHashMapFromArray [10000, 20000, 20000];
_hashmap toArray true;    // returns [["cow", "cat", "chicken"], [10000, 20000, 20000]] - same as Syntax 2
_hashmap toArray false;    // returns [["cow", 10000], ["cat", 20000], ["chicken", 20000]]
```

## See also

[set](../commands/set.md) · [resize](../commands/resize.md) · [reverse](../commands/reverse.md) · [select](../commands/select.md) · [in](../commands/in.md) · [find](../commands/find.md) · [toString](../commands/toString.md) · [count](../commands/count.md) · [deleteAt](../commands/deleteAt.md) · [splitString](../commands/splitString.md) · [joinString](../commands/joinString.md) · [toUpperANSI](../commands/toUpperANSI.md)

<sub>Source: [BI Community Wiki — toArray](https://community.bistudio.com/wiki/toArray) (revision 377121).</sub>
